|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 d6 o& ~. [' U$ l#include <linux/init.h>3 B. `1 j5 O P$ m& }6 ~* Q
#include <linux/module.h>) m8 N/ o7 q' W* Y4 |, C9 V v
#include <linux/kernel.h>. n) h; K9 I! }, E
#include <linux/types.h>) p' D4 e' U3 k" p' I2 x7 w
#include <linux/gpio.h>! H v8 u# E6 h1 r& b% {& f/ ~: A
#include <linux/leds.h> W: G8 g+ f# J
#include <linux/platform_device.h>+ [; R4 P8 U$ Q1 f% _7 u
% ] k1 b) i% B0 q% y0 b1 u#include <asm/mach-types.h>$ }! {* o+ G4 F' B6 Z3 t* I
#include <asm/mach/arch.h>- p% S1 Q. w5 X) j
#include <mach/da8xx.h>- h% w9 k. O) D
#include <mach/mux.h>5 C q- d% z6 s0 q) F
* [/ r4 |/ W' b7 n4 k! I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: f5 n& H6 t7 X: M( H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) k4 [2 E# v3 j1 ]1 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# ~! @# `( ~5 d! S) j' B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 N- D2 ]+ P0 h! [6 A
' z: d0 a4 U# ^' }4 ~/* assign the tl som board LED-GPIOs*/. a2 w j, }% a7 K
static const short da850_evm_tl_user_led_pins[] = {$ d1 c+ B# j' U$ s% u2 n5 R) w
/* These pins are definition at <mach/mux.h> file */ N% P+ D9 Z( M1 g2 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; `% V3 _1 D$ e -1
+ E0 [9 F4 y' x& f; I};3 ?* @( Q% ~$ `, O: S1 h) v+ E
0 i% h0 `. D% w: X
static struct gpio_led da850_evm_tl_leds[] = {( o) w0 |& s4 s( P2 \5 ~# v& c: l- ~3 U
{0 }4 z7 t/ h0 x, |( ?3 |5 q
.active_low = 0,
: L3 Z' L- O' q ]# B .gpio = DA850_USER_LED0,
6 \+ \) b* [4 C i .name = "user_led0",% F* O/ S+ r& e( O8 ]- _. }
.default_trigger = "default-on"," L+ Y. T* W/ R# m
},
" s. y7 K. t# v6 i' P {8 E1 t/ d( X3 B$ P2 U! q! N
.active_low = 0,
8 }, p; d" |! F .gpio = DA850_USER_LED1,& x- v" v* o# m/ k# j- v7 ?9 i1 |
.name = "user_led1",. c$ X4 u7 X: |' Q2 L% D$ f7 W# b
.default_trigger = "default-on",
9 n, H5 a0 }6 X1 }, f' m" f+ d },
. o: P) x6 g. o! f2 q0 ` {8 ^ \9 T# B& N0 j; ]& h. d
.active_low = 0,$ |4 y+ ~7 `) w5 c
.gpio = DA850_USER_LED2,
- I3 K- U9 |# m2 l .name = "user_led2",
, u. N4 y, C! g- ^$ a# ] .default_trigger = "default-on",- q$ y6 q- M. k. S+ N
},
" E( t; s/ M2 x7 e7 V1 n {
4 \+ L0 [6 m5 o) [+ t2 n# q) Z" J .active_low = 0,9 _8 B. z1 q* X4 U7 t/ ?! b0 V3 O- n; R/ B
.gpio = DA850_USER_LED3,
2 f7 o9 x( g- F$ u P" p) g$ H; n .name = "user_led3",
7 |1 L4 t; d# d" |- ? .default_trigger = "default-on",/ R. Z- E' ^, b, o( q
},
2 G' x2 D$ @: Z4 k};0 X+ { t& j1 P& b$ `/ U" E
: b" L E& g$ G/ b) A" ^2 ?$ n5 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 |, Z, r0 ?% Y% C: |, g) h/ g .leds = da850_evm_tl_leds,) j9 u0 H# L- B y. H' Y- @& I4 K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), Y5 L% Z; K7 _/ E/ O
};' D" S6 I5 a) s
& R; u9 }: [# |) _$ _
static void led_dev_release(struct device *dev)0 d! X b N" [" h
{/ G( |( W0 b& |7 @
};
: m2 S) E2 t p ?5 @$ R+ [' _5 W. k0 t+ h, U! \; o
static struct platform_device da850_evm_tl_leds_device = {* }4 e. D; ~+ g! S- S
.name = "leds-gpio",1 @, p" f6 a: Z: ^! z+ p
.id = 1,' Q( V. [2 H9 G/ a* q1 Q" H
.dev = {
* s5 p/ y/ E- w' ~1 D .platform_data = &da850_evm_tl_leds_pdata,
# ]( v; {( o6 ?6 `& B6 y U .release = led_dev_release,
. c9 q* H# [1 Q9 L/ n8 | }6 S( v- d( n# Z4 y1 p6 B8 L
};) M! o2 n, ?% Z
9 s2 J. f- p& U, _: istatic int __init led_platform_init(void)
* X$ y) k) j' ]6 C( Z5 t0 {{& P2 T8 A- P9 ^" C# j- G* C, ^
int ret;+ t8 @( B2 y5 D: }) o
#if 07 p* R' j( g4 @7 `) n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ U5 T# `6 g3 E* D' g' f1 G; K
if (ret)3 g$ A% k0 X+ A o. M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! @% e/ G# [# L) z5 h "%d\n", ret);
( X: {: I2 _1 ~( E; p0 I#endif! o! K6 O* @! m
ret = platform_device_register(&da850_evm_tl_leds_device);! s' v \# y1 B, m F6 t
if (ret)( ^4 \, v: W$ M' a3 L
pr_warning("Could not register som GPIO expander LEDS");
9 z0 A5 r4 x9 B else3 d6 B% b3 H3 T: Q. z
printk(KERN_INFO "LED register sucessful!\n");6 l. j; N5 B& `. k6 B, J0 I
- ~) B* x& |( {/ P return ret;1 _$ R! Z3 v a9 I( z" T7 N' o0 O, j
}) [. Z# A4 {+ V5 T" a7 h
! g6 v, q( X2 H9 R0 lstatic void __exit led_platform_exit(void)
$ G; N/ ~* U L+ I! T. G5 `3 h# J{3 A% d9 ~9 p" Q6 D. E5 E
platform_device_unregister(&da850_evm_tl_leds_device);
( X; w8 G5 f, ^3 ?3 q% |& L( F
% w3 b- s! S; m printk(KERN_INFO "LED unregister!\n");3 Z# d. Q0 s# ^& t
} E# M$ h; B5 r7 r9 w6 c
' d2 @) T) W, K# E) B% {% `module_init(led_platform_init);
- b9 o9 J9 {$ r* _* r- c6 ~' ]) Umodule_exit(led_platform_exit);; {' N: X' B& @& x+ f0 V0 m: g* }* |* d
9 S* @6 i) ?* O! v; V$ r0 s
MODULE_DESCRIPTION("Led platform driver");
3 P: S, w) [# u. D/ ^4 l* AMODULE_AUTHOR("Tronlong");+ ^+ O5 {2 W9 ^& j! J2 x
MODULE_LICENSE("GPL");
8 T1 k, S1 S. |8 @, b. K) @; ~
6 y4 b+ t- H* e& x( c |
|