|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, O8 ?- D! i3 {5 O. Q4 S
#include <linux/init.h>
) [5 z) _: ?9 l& C* H- k1 I#include <linux/module.h># l# D/ m8 A! ^9 r, V* J' R( X( A' d" R
#include <linux/kernel.h>6 q- j* [3 i' c" [: r: v; \
#include <linux/types.h>
7 ^% f2 `: N) E#include <linux/gpio.h>
2 Y: t" o* V t9 M g#include <linux/leds.h>% w; C: ]- d9 H/ o! f6 l+ I
#include <linux/platform_device.h>2 o4 E' n" U9 o% n/ x2 B' b
# x" F+ b3 i4 K1 I% @#include <asm/mach-types.h>
# x- y! Z; Q$ X#include <asm/mach/arch.h>
6 \) X; @& F& T; `* p#include <mach/da8xx.h>
3 _$ ~- k2 q: ~: P7 C7 l4 R K#include <mach/mux.h># E9 Y, r4 f2 |; ~; v/ N
6 p) ]# D- y8 U% c! [/ L' a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 X' `( y, E0 {. `, Z4 ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 D$ U s# v; c! ]) T9 h/ A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 w8 T$ `& }% d7 J, S7 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) x5 n) Y) u! Q: z9 K4 E/ Q! Z$ W& ]* C
/* assign the tl som board LED-GPIOs*/. o! l: T& o9 t9 R
static const short da850_evm_tl_user_led_pins[] = {; B5 C' {! v+ ^- @* e! v, F
/* These pins are definition at <mach/mux.h> file */0 u3 }1 D1 c3 x2 s/ p: G1 S% L; k8 `9 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 F# z5 U! j( W: g/ D
-1
) |6 u1 Y9 i8 F' J/ w};# V X8 N) n- K! \3 F
7 |) C$ a- `7 J p7 L3 {
static struct gpio_led da850_evm_tl_leds[] = {: T" T( Y, j2 h$ a/ i
{
3 M ^2 u1 t& U* r .active_low = 0,
9 A) t, F% e0 i( ] .gpio = DA850_USER_LED0,+ r7 @: ~- W/ o3 R; E# k; C
.name = "user_led0",+ p# K! Y3 x3 B4 I% S
.default_trigger = "default-on",
) m- o5 V7 c# ~1 g9 F6 V },
% F' p+ c& ~( S+ H+ R {! j" y0 I* {7 Q
.active_low = 0,
2 `! n ~( ]" B$ u5 y# F .gpio = DA850_USER_LED1,
" p$ p; S2 K# z* }5 Q6 e .name = "user_led1",
& `% G5 {/ g4 C .default_trigger = "default-on",
1 s* ?. H# J) W },) h+ C/ Y3 @6 Z
{
# o8 ~* r) v8 ^ .active_low = 0,
: s& D r) r% ?. M6 n- {( @ .gpio = DA850_USER_LED2,0 a* T5 |7 I+ H9 D8 h8 J& n* |
.name = "user_led2",1 Y% m2 d9 U9 g+ \
.default_trigger = "default-on",
* w: b h) z% u- T P$ ~; j },
# g' N5 ^8 G t) ]5 C) }, e! _ {
; f/ ]+ g4 i# T1 K) S .active_low = 0,
|# s% s7 w2 C, v2 } .gpio = DA850_USER_LED3,) L( d4 Y {5 ~( k. k( e
.name = "user_led3"," G$ S$ s" }) p U1 n3 V8 c2 y" E
.default_trigger = "default-on",
4 h0 E# {- ] p* B$ Q5 T( z },
6 E9 E! b2 g4 E5 h: k, ]0 j};1 S* j% d3 S( O* B( J$ V
! R# ]' h" c# M A$ V9 m$ E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% k: I. |/ T8 ^+ {
.leds = da850_evm_tl_leds,
/ S% y) {: m* n, g7 L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! Z8 O1 V3 H& b& ~' [0 d
};
8 n+ {5 }/ W& j, L: a
. t( x. E4 w/ C8 {2 gstatic void led_dev_release(struct device *dev)3 ?9 \- L! L2 X* S; W
{. _# A+ `4 Y3 g/ a
};
8 U; r: A4 j* _
8 R; j5 \0 f) |( D9 Gstatic struct platform_device da850_evm_tl_leds_device = {
5 W/ @( x9 q ]' k d' W# P! u .name = "leds-gpio",% D- _0 G$ P2 }) `2 C
.id = 1,
, ~4 v! T, l, f0 Q+ n5 ?! } .dev = {
: G! B# Y: Q* i7 O/ n# I! @ .platform_data = &da850_evm_tl_leds_pdata,/ v: v4 U- W: q' Q Z- N
.release = led_dev_release,
: v" k D& Y" J, Z; |2 t5 L }/ |- j/ b3 m8 b1 K5 N
};
7 @; ]5 g* J* Z( {) o( P* q6 Y* c1 \8 i! \$ m
static int __init led_platform_init(void)3 X0 B, s- O' P: [
{
( Y9 A& ~. \& x# R) K* y int ret;
7 N X" Y, q- b# [& t" z! R" ]#if 04 {/ T. l& e6 v3 V( n1 Z: B% q2 h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ D% b; J& [; Y( a$ T0 V
if (ret)
1 ^ M3 F, N. K* I" V5 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! j) o1 W, v: y8 j9 @+ g: b "%d\n", ret);
1 e. M; S/ y- r, M* t#endif) t! j: w+ Q L, l" o' h& ^' ]
ret = platform_device_register(&da850_evm_tl_leds_device);3 C) o0 ~9 T2 Q+ F" l/ N
if (ret)! o/ @. U( [7 g4 T, @8 z0 n
pr_warning("Could not register som GPIO expander LEDS");
) R' t1 o1 a9 r else
2 T( H" j4 O* q, L, p/ u1 D. S printk(KERN_INFO "LED register sucessful!\n");7 P& E9 S: S) Z4 i
- s- V4 _; ?/ M, d6 s return ret;
) P& F6 {' {+ ^9 C& W}) @" y4 {" I; O6 L
: g: t Z+ a" Q, Q D
static void __exit led_platform_exit(void)
& X% M$ L6 b U{# U) ?! x+ b. z) E! f
platform_device_unregister(&da850_evm_tl_leds_device);
4 [9 L B [9 j( ] T
' d0 ]+ w0 q! ^7 |. S printk(KERN_INFO "LED unregister!\n");
& k/ X1 }% }* O+ I1 p: R) t}
/ A0 y1 C* B4 }. {. i+ N8 v6 d. ~0 E4 k' f. s) f2 h
module_init(led_platform_init);2 K$ U3 Z+ m) {& @- i( W
module_exit(led_platform_exit);
I3 E( b7 M- n! M; j7 l( y$ n K7 Z$ S
MODULE_DESCRIPTION("Led platform driver"); O) }" `* P, h- ^. o" b
MODULE_AUTHOR("Tronlong");
6 l5 M) |0 C0 U$ h' m% w4 \1 tMODULE_LICENSE("GPL");/ ~, L* c4 o. s- f1 f
/ @3 e( q0 a6 F, v
|
|