|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 U! L) ]- w$ L: O- Z
#include <linux/init.h>
5 ]! \- A: z' F#include <linux/module.h>" b8 ] g6 R# K1 X1 D4 v+ ^+ u
#include <linux/kernel.h>; m6 t& ~5 \' U' `' P5 T9 e
#include <linux/types.h>
5 } w- [ V7 g/ ~% c( A5 l$ L( a#include <linux/gpio.h>9 V% `* S& q" D0 s! g
#include <linux/leds.h>
% v2 x! z ]' Y2 D#include <linux/platform_device.h>9 L2 ]3 {. {9 D2 e0 O
( @6 w1 g5 [% m( b: Y
#include <asm/mach-types.h>0 L" A$ B4 ]. m$ B* \$ c5 c
#include <asm/mach/arch.h>
" J3 r* Q' b* n8 m# ^#include <mach/da8xx.h>' D5 g. y4 K3 w/ |# {
#include <mach/mux.h>9 g. A9 Z" c2 u F6 H3 ~2 ]7 n
8 V3 M" L' b. @! l& f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 s" D& p+ A4 |4 W$ g% c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) F5 }3 u) ?# g+ Q1 V" Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 a* S1 ]& X- u- ^. ~5 m& T- Z* O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) o: z2 A4 U, b% E4 |; @
- c0 B( R; _6 S/* assign the tl som board LED-GPIOs*/% K2 n; o' ?$ h5 X1 d
static const short da850_evm_tl_user_led_pins[] = {1 K P3 z1 v! m L
/* These pins are definition at <mach/mux.h> file */
2 A3 y- l" r* M) p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: Y, W2 v) `( ]3 x$ h$ l$ a -1$ A0 C/ c2 M2 y# F" M8 r
};# D* _+ p1 ~6 C( m) r# r
3 y3 n% U$ n g, Zstatic struct gpio_led da850_evm_tl_leds[] = {9 b; W+ T4 o* n1 b
{
( c2 U+ q; b2 @ .active_low = 0,
. ^* Z& {, Q- R0 C .gpio = DA850_USER_LED0,5 u! N2 E5 h4 L' v* m
.name = "user_led0",0 w3 i5 ^! F4 |. O8 F
.default_trigger = "default-on",
8 N- t+ e; D5 J9 R" O8 { } },* }$ Z3 Y0 ]: p
{" F. ]7 V9 T" q! H+ C* E4 A, |
.active_low = 0,0 f7 w# `( k- |. r/ ^' P O1 M
.gpio = DA850_USER_LED1,
! ^9 k1 s& `8 i .name = "user_led1",, s) r! Q# b& u2 Q& n4 ]( {
.default_trigger = "default-on",2 t: ]! v3 A9 h; c
},
) m) p+ O. l. `+ b {
( |7 Y( |, S0 } .active_low = 0,
7 `3 q. W7 s6 m .gpio = DA850_USER_LED2,
8 E; t; J! w. M. z8 }3 A4 c .name = "user_led2",
2 ?0 ?3 S% h5 Q \ .default_trigger = "default-on",
\6 `9 k C* b! s0 v },
4 v& y5 s- s: _ {
1 }, `) `) I+ K! l4 O .active_low = 0,0 @' D6 `8 r; V9 U) b5 x- z7 z
.gpio = DA850_USER_LED3,6 ]0 c; l' q; A3 Y' s- r* N. @
.name = "user_led3",. g( g' ]" u" Z* G# i! r5 M/ I. v
.default_trigger = "default-on",3 y$ h6 D! b% D
},
# }- F; _/ V" V/ C};
$ }6 V/ h8 Z4 E& \( {# [) n
+ r3 s0 x, Q( ? a# G, I/ cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 `4 U! M, O3 {; B, m% S: ^! _ .leds = da850_evm_tl_leds,
$ |" Q; _- g; R/ ^- _4 B4 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 U# z3 A! ]: K! V' k+ z( ~+ d9 J
};% X& ^2 G3 c/ v/ [: H
8 d4 j5 o* h7 J3 r+ p# V0 i' X% E) o/ k
static void led_dev_release(struct device *dev)& N4 [) A* i7 o5 w7 R; v
{
4 |$ w7 f/ g- X2 E, {) A' O* U};
# v" N9 T4 Z2 H) |, `1 P
6 M/ U2 j+ y( d! d3 d- Q+ Bstatic struct platform_device da850_evm_tl_leds_device = {
+ s k0 p" _8 t8 X, x8 x; R .name = "leds-gpio",
8 J3 \6 m O. m .id = 1,
; U y+ v! h2 c$ n .dev = {3 J+ e2 |& ]5 [' g6 ~, O, I: [& p
.platform_data = &da850_evm_tl_leds_pdata,
; P8 g' W5 M* Z .release = led_dev_release,
, J8 n( X- e- i }- u+ p% J) N% m7 N2 ^! O. G$ t
};5 r6 y* Z2 t1 `# n, b
/ l6 @( A" x+ G8 v8 }
static int __init led_platform_init(void); ?( `1 f% z: a+ y3 ]5 b
{
4 X$ P4 Z- o" h/ ~ int ret;
2 d4 g) B2 ?$ |' ]7 e#if 0! U$ {6 M6 \& V8 Z& H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* z- m9 M* T3 f, r: Z' J if (ret)
1 h/ K) n B+ Y+ t pr_warning("da850_evm_tl_leds_init : User LED mux failed :". [, R" v0 I8 T4 J* K
"%d\n", ret);
" j% y; C# a) C5 r: U. `; I; J#endif: `. S- o, m2 C' y4 R. D) a
ret = platform_device_register(&da850_evm_tl_leds_device);3 i! i g1 l- s* n6 w
if (ret)- B) F7 E- X% H$ P1 v( c+ P
pr_warning("Could not register som GPIO expander LEDS");
+ q/ }3 `! @3 `: ]) x% }4 k else! V7 d9 ]1 d: C! Q
printk(KERN_INFO "LED register sucessful!\n");. C& v' K# {' i6 a/ o9 M+ U
( {# t& e5 I) }! K" [9 W& t8 f return ret;
5 A1 @- t5 B0 e}; P$ a9 ^$ {; W2 c" R
% }/ X8 q8 s+ |: U% sstatic void __exit led_platform_exit(void)
: x- d& B/ P1 j m- g- |0 a* b{2 A) e7 U) f/ o
platform_device_unregister(&da850_evm_tl_leds_device);7 a! q, d* s. F {" o% a7 k
9 n) M/ [. ?4 S) d printk(KERN_INFO "LED unregister!\n");
7 \% v: C! a/ c7 S8 u}; {/ u$ A6 O6 i; p( j/ ^+ }
* g5 D& p% X6 m. F! A+ pmodule_init(led_platform_init);7 Q E$ x! @0 |1 L! a
module_exit(led_platform_exit);
9 v& S( a+ |. }2 B( s5 P8 _4 ?5 i
MODULE_DESCRIPTION("Led platform driver");& q) E8 Q% [0 J( F7 I. n
MODULE_AUTHOR("Tronlong");
( B' e ~7 W7 H! L$ ?3 ]MODULE_LICENSE("GPL");
* z: j0 K; t! ^: F- j* v
$ E' }* y; v% f) h) Z* c' S |
|