|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% k6 p+ A0 h( w8 G3 J#include <linux/init.h>
; \7 i, A8 W3 t2 y#include <linux/module.h>
7 G G& J. Q* L#include <linux/kernel.h>
0 u: z9 r0 V3 b* V+ I#include <linux/types.h>
7 Y- O) y$ |' o1 s4 o#include <linux/gpio.h>0 X8 M% ^+ v5 S+ Z
#include <linux/leds.h>
# g1 v6 ?5 g% W% K- B0 S#include <linux/platform_device.h>
5 ]2 r$ a$ U1 X) h8 G- A4 I t, O' U: n5 G9 o
#include <asm/mach-types.h>- j7 A9 T$ W" K3 v8 `7 Q$ e1 g3 U! V
#include <asm/mach/arch.h>
/ a- J! v. q$ f0 ^#include <mach/da8xx.h>4 a" G# l; Y8 \+ x7 R0 x: V9 e
#include <mach/mux.h>8 g3 l5 W3 K$ ^& p
- Z" [* x2 v5 _4 ~1 R' n7 I# [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 m% S; w7 N6 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 C/ b+ X" j* R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 L |# D% h7 A1 B/ i- N% f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ p0 v7 O6 y& G* s- B) U" d( e
* h U3 A' \% l; @/* assign the tl som board LED-GPIOs*/' i' z& N8 D, }
static const short da850_evm_tl_user_led_pins[] = {
; J5 S: A1 X' v- I /* These pins are definition at <mach/mux.h> file */1 |0 x) u0 }7 k: `, {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 O1 S5 F' y8 Q$ O
-1
2 |* Q: I. W, R* I' G};7 Z2 s: d) i( c
/ U, ]2 K9 T [. s! K- ~static struct gpio_led da850_evm_tl_leds[] = {
3 u |0 X2 q( h) {5 p* W) M {
$ J: ]; n; b+ W' @3 a* i .active_low = 0,8 d- h2 c9 ~7 |+ I9 ^. L
.gpio = DA850_USER_LED0,
+ {3 v$ g% S; ~9 G- C& j* }3 y .name = "user_led0",7 B& f$ Z5 c4 H' l2 a
.default_trigger = "default-on",2 V2 ?' \/ M. _$ O8 M. v
},
- O. c: `$ k, o6 E0 a8 U. V {
. @1 P5 e) P) i" Y; X .active_low = 0,$ F! ]; [, R* s! S
.gpio = DA850_USER_LED1,
) W0 g; j& c3 b3 o& H1 w .name = "user_led1",
, K0 f& u+ w' ]0 Z! S .default_trigger = "default-on",5 I* i& ?* O: t; v3 K3 O( Y
},0 [- e! L. ]# [
{
* v0 F& K% |7 v4 b .active_low = 0,
9 Q3 h, u0 U7 I, o( g4 x; g .gpio = DA850_USER_LED2,8 | [) {" y* Y- U$ c, R
.name = "user_led2",) Q+ n3 M+ F$ a( L) T
.default_trigger = "default-on",3 v2 }" D2 Q) h3 ^
},
% d8 P( H! O! S! ^; I {0 a4 `- b1 f1 h" j: `5 f. P
.active_low = 0,
# v, W* j6 Q# b4 D" D, r .gpio = DA850_USER_LED3,
( U" l, z/ g8 @' _ .name = "user_led3",
) J; B; e8 M2 C. v! Z2 e .default_trigger = "default-on", A5 `0 U7 f6 \7 N# z
},/ t4 Z( s# i5 h) u& u, L
};
4 H. Q0 I: f( C, {# e8 H! k9 v- ?$ D4 E$ F+ ^, L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 |# Y2 T4 c+ ]: J
.leds = da850_evm_tl_leds,% N5 C. p2 Z3 i& H( c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 i& S! n N: R8 ? f
};7 X" u$ d3 }2 H" b7 ^
* [4 O. O' g" i( f ~' j# ystatic void led_dev_release(struct device *dev)
6 s( z5 f! h" m1 \3 R{
+ ]7 z/ n! q4 a) I& h9 S& V};5 l" F9 s( l5 W: M8 Q
p9 ]; V( [( ^6 x" p6 ustatic struct platform_device da850_evm_tl_leds_device = {+ ?0 N/ Z7 J2 K ^7 X# N
.name = "leds-gpio",3 q, m Q( o6 }4 K
.id = 1,
& K6 i4 j% {/ h* b+ g- ]$ a5 e .dev = {' C+ w, l+ h8 u1 q& S8 M
.platform_data = &da850_evm_tl_leds_pdata,
+ {: k$ C. h/ f4 W .release = led_dev_release,
; B5 Y ?1 {' V! k. _ }
% F) E& N% Z9 b" f! V};
4 H5 B4 B$ w/ M- W$ ?+ M# V8 [$ C. g6 f# u0 c
static int __init led_platform_init(void) e% l: z, G7 \" ?5 p V2 p
{
H: A$ s$ C. E# x int ret;- z7 U1 b3 q! P3 K5 o+ [* a
#if 04 [8 r0 E$ r" r; y3 `8 b2 v7 c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, U1 I9 ?, ]! R3 }
if (ret)1 T+ u& ?* B- H4 y# i1 b: A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; [( r) U8 O5 K3 a1 S: ?
"%d\n", ret);# {/ x$ ]2 U0 E9 t/ y3 a
#endif6 g; W( N& I4 C2 k+ ^. v
ret = platform_device_register(&da850_evm_tl_leds_device);
( J- A+ l( D/ h; U0 h5 L3 A+ L- o8 k, D if (ret)
8 u, R2 u2 ]# z9 n- w pr_warning("Could not register som GPIO expander LEDS"); L* O# Z( X, F$ J
else4 {. a+ ^3 _7 n+ i- j
printk(KERN_INFO "LED register sucessful!\n");
. X) m u6 N7 X
* w& @+ ?# f1 [8 \" x return ret;; W1 b; c- L8 S
}- ?" K$ D/ T/ A" G7 {/ i2 d
/ w/ Q9 O( q" h# J' q4 r5 j" B
static void __exit led_platform_exit(void)
5 U9 G9 _: d) E/ X5 \{5 M+ { i3 g9 H7 Q0 E& W% W) l7 }9 |
platform_device_unregister(&da850_evm_tl_leds_device);6 \; ]! @4 |* a* Z# x: t i
, s/ Y' w0 e: Z7 c$ _+ ~ printk(KERN_INFO "LED unregister!\n");+ @; q# T; \# c0 q
}: }6 \ |- }2 O, S2 \& E, }3 B
1 P2 O2 p2 l* \# xmodule_init(led_platform_init);6 t5 x- a4 K- k3 J
module_exit(led_platform_exit);. L; h7 t7 Z$ A+ |. u
" h7 ]+ B) D4 _) d- ?MODULE_DESCRIPTION("Led platform driver");
2 a1 ^* f5 h! U& Z) J1 X& OMODULE_AUTHOR("Tronlong");4 {8 W0 @6 J6 D3 \
MODULE_LICENSE("GPL");" N, Y% ?4 W* k: W2 }. |
& u% ^( V: ^ [( J |
|