|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( I$ c5 M0 [( o2 v9 O+ l# x
#include <linux/init.h>' t/ I1 m/ z. r9 f& Y
#include <linux/module.h>
6 Y$ E. j9 C5 [7 t7 Z0 p$ X( ^7 b#include <linux/kernel.h>
* C6 _* D# O& y; H; H" b#include <linux/types.h>
# Y6 }9 Y9 P; F9 F3 ?#include <linux/gpio.h>
! P* E% L0 ~' u#include <linux/leds.h>" K( t; c8 ~ V: Y1 D t5 ~
#include <linux/platform_device.h>) I" B; X) P5 `8 O9 Y
, X' z: I' L0 I3 o) L#include <asm/mach-types.h>& ]; b: y) ]' c1 ]1 D2 \, h" I
#include <asm/mach/arch.h>
8 _( J0 N; c9 S( D3 `# g7 D#include <mach/da8xx.h>
( x1 B8 z) {) G* @2 o. Q" U#include <mach/mux.h>
" q+ w* h* v, z
4 `2 D1 }9 s& }8 w1 E3 \( k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) s2 Z9 ^& @( X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& }, h/ J0 w2 X0 f: D R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' g4 S/ Q+ @, q4 G$ b$ _0 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- X9 S9 m) Z% i6 R7 v' J0 B/ @' m7 A( M7 `. f: z; m
/* assign the tl som board LED-GPIOs*/
! s, c/ u7 k( \& F sstatic const short da850_evm_tl_user_led_pins[] = {! G2 g e8 a% \& J) k9 T
/* These pins are definition at <mach/mux.h> file */
: m$ V; K! U6 z1 H. | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% j: S5 B/ V9 N+ e, @$ P# B -1. b( W/ |+ }$ i Q; e% L) U9 D, \
};; l# I5 ~. g, A' m4 Y
$ e! [7 X+ A* U4 n* dstatic struct gpio_led da850_evm_tl_leds[] = {
& ?+ q! S) j$ [. H9 p' y {
6 Y0 r8 O6 n* M% Y9 a, B6 q! ~! v4 b .active_low = 0,
: \9 ?/ |; V( K! C- C8 P- h7 H .gpio = DA850_USER_LED0,; g% \% a! \4 k/ a
.name = "user_led0",
# S w4 T i, V/ \$ d; I .default_trigger = "default-on",: N* \; Y( Y0 s5 K1 L5 S$ N1 j Q
},/ f; L% @- i. T3 j! d% ^( Z
{$ X& Y& U6 r4 Q0 y% z
.active_low = 0,. X/ N W4 E9 c
.gpio = DA850_USER_LED1,
$ E( s$ n. N+ h .name = "user_led1",* j# ~; b v5 x7 B
.default_trigger = "default-on",
# ?, R3 ^: a2 ]# P% h, P+ G },0 m1 M8 o5 u& ^
{6 S; P* H( F+ d6 J$ X4 E
.active_low = 0,
- v0 G! @8 }* }) n' D/ M .gpio = DA850_USER_LED2,
+ d- b }' K0 O- h6 C .name = "user_led2",
! [. z; @& T" T# W3 j0 F3 F; E: z8 r( Z! } .default_trigger = "default-on",3 ]. q& W4 C3 ?5 Q! H( u9 |1 n+ `
},
/ x+ b- |9 c8 ]1 |& @ {
@2 D9 \% Z; k& K4 h% _) g .active_low = 0,& ~8 n* d o4 t9 ]
.gpio = DA850_USER_LED3,( v$ {4 q2 O- A( l
.name = "user_led3",
6 H! l) H# u+ N8 ] .default_trigger = "default-on",
7 @, J* r7 _( w/ i" x },* a' t E" K- P7 z. V. T( D
};8 K" g: P$ t6 G- G: b% a4 F
% y' L0 n/ @7 p9 A; ?3 D' v" G2 i! o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 S. C( Q2 t3 D5 | r .leds = da850_evm_tl_leds,! X. m5 g/ p- d# R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# w9 {2 r# F* m$ Q$ ~9 K
};
0 h" k9 a a C% ~& J: s+ v# b/ b0 B! }4 \3 i, L
static void led_dev_release(struct device *dev)
. _) A9 E- F+ }% ` v$ j2 d{
3 \, U. ?3 K2 K};
% S0 U% S! J' F; {; s$ H7 ?1 b: n8 y9 Q) f
static struct platform_device da850_evm_tl_leds_device = {
8 ]) V$ c' Q; C1 Q .name = "leds-gpio",
) D: u5 y) R3 U' \( B0 x, @ .id = 1,9 e" @# z6 p$ d& S2 k; m
.dev = {
3 E( K6 w" G3 @7 I .platform_data = &da850_evm_tl_leds_pdata,
) ?/ U8 g4 w% Q( A K; x* N .release = led_dev_release,
9 a& k' Q5 T* {2 ~$ ^ Z }3 @# O% A. t, y3 ]+ @; z l
};
" Z' m- ~# G3 H3 a. Y+ Y5 T
" A+ V' h1 M6 k. p! g/ ^* L# Jstatic int __init led_platform_init(void)6 {. Y) c, p: W2 q2 w. L& e
{
! F! G3 a( m2 V& I4 R6 T" n int ret;
- A5 h ~" \! b9 {#if 0
6 E' S r2 R: o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. f/ B/ d2 m3 K) l2 A if (ret)
0 ?, [ E, n+ P1 R L, C pr_warning("da850_evm_tl_leds_init : User LED mux failed :", V5 X6 N# H) _5 |9 g0 J
"%d\n", ret);
2 E) F3 I4 K$ E#endif! D% q% N0 e: V Y Y
ret = platform_device_register(&da850_evm_tl_leds_device);& z! j4 r3 |" R8 Q) [
if (ret) d9 x5 Z: f w) Y+ \! U
pr_warning("Could not register som GPIO expander LEDS");
' a3 v/ B3 Q& `! _! F: h else a8 ?5 R; Z# R
printk(KERN_INFO "LED register sucessful!\n");/ t- _' Y+ _1 C4 A5 t
) p$ _) C9 r8 n. I7 D4 r return ret;- X/ O: r) w: @4 V+ P( V$ r0 v7 M
}
2 f# C! Y% J' P( `# q/ @' G/ O3 J. u$ X8 f2 e2 F9 y
static void __exit led_platform_exit(void)
6 y1 \8 E) r! g: `) x( e# V{2 d, R0 Z/ i/ q/ ]
platform_device_unregister(&da850_evm_tl_leds_device);: t( ^2 |, m+ _" G3 ?/ V% b
2 u+ l \ q1 X% H3 r; H! B( Q
printk(KERN_INFO "LED unregister!\n");; \+ X4 ?0 J& o$ k! p* I
}
: k; l/ `7 S1 Q: ]; e b
% |1 _& U% P% x$ z; I1 W* f( F( Omodule_init(led_platform_init);
$ [ J5 V! x) A, m# J9 S2 U8 g% Zmodule_exit(led_platform_exit);
; p9 k: }+ w. D9 c' T2 \7 X+ L( |& S( |3 t
MODULE_DESCRIPTION("Led platform driver");
9 j0 u/ N7 l5 ~: W' l1 b6 lMODULE_AUTHOR("Tronlong");
- A0 c( h$ I6 r E7 YMODULE_LICENSE("GPL");* S0 t! m! y: j2 V
6 ~$ E' p0 O+ v7 V3 m$ J9 s |
|