|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 F, t- s; y* \
#include <linux/init.h>
$ C n F$ S) ]- ?+ D1 E4 h* O#include <linux/module.h>9 m, u2 R2 ?$ O
#include <linux/kernel.h>
9 s2 Q7 \7 a, f% ?/ D& ~#include <linux/types.h>. z- N# p9 g, H9 A
#include <linux/gpio.h>& T! \% {& ^. i) x$ s
#include <linux/leds.h>. L0 o; z* _. W7 \5 d+ {
#include <linux/platform_device.h>
0 b# P# u( h2 U7 ?* C
) T; B+ O8 E) Y9 Q: C1 G3 Q#include <asm/mach-types.h>
3 F2 L$ H; z5 U#include <asm/mach/arch.h>' t% y: `: L$ ]. w. a& ?9 B% b1 M/ q
#include <mach/da8xx.h>0 l6 Q0 r- k* E8 ~8 n) n
#include <mach/mux.h>% ]" w7 J; y9 }
3 Z/ E5 Z( Y, O0 `5 z3 h8 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, i7 M2 b' ]' O/ P: L7 k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- H% v) j- I' J' H- I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 O9 c7 b5 I5 x& s5 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 g2 [5 x' g) O3 E; j2 K
! g) K3 u y7 F! D; p6 s" N+ V/ h. k/* assign the tl som board LED-GPIOs*/
* i3 R3 e8 q! o/ estatic const short da850_evm_tl_user_led_pins[] = {
! f# l- s2 a! K d$ [* J /* These pins are definition at <mach/mux.h> file */
`* y. Y) F9 b* h7 f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ }, k6 Y6 X' } E' A
-1
4 l: y. F2 R2 i5 O- V. |};
# v; `9 U" Z" @- D. U; w/ R
" x2 T9 a8 l# e& f# L3 astatic struct gpio_led da850_evm_tl_leds[] = {
w8 A$ q" C: `! e! Q% s( W8 w, x! l! ]* r {3 B# ~, [: p* Y
.active_low = 0,' a! O7 \( x- w# E: g# T
.gpio = DA850_USER_LED0,0 j8 i( b a0 P. y \/ O) O, q
.name = "user_led0",
& b; h- y' L: V) K- N* U .default_trigger = "default-on",
i; y2 r& i6 R$ x: ?7 l8 e },
, U' P( E, I4 ] {+ ^3 E8 ]( m: s, ]& ]2 ?( I
.active_low = 0,
& L2 h; h- c$ r5 C. n2 c, c .gpio = DA850_USER_LED1,7 S0 `* g* A8 N3 x; Z1 E& q6 ^5 Q' H& X
.name = "user_led1",3 U% C$ h' E, _, T0 u
.default_trigger = "default-on",: Q1 T3 g0 b3 R- A* Z
},; s" f4 v$ |! a& y3 f' h* A* i7 A
{
: {3 r8 T) j9 k( G .active_low = 0,1 B; j$ G1 C% T9 ^
.gpio = DA850_USER_LED2,1 d0 E1 \' u% X- X- d* V! z
.name = "user_led2",% e& L$ L8 ]+ ]6 p9 ?9 u' j0 E
.default_trigger = "default-on",: M! B& a8 J* L3 `
},
u+ @! @0 \; i' R2 f* a: t {; M0 I- Y' w( c- A, a
.active_low = 0,
, z0 [: k* {0 b! M/ y3 F' M .gpio = DA850_USER_LED3,
8 U# \+ S/ l) o6 S .name = "user_led3",
: w$ ~" M7 Z4 _3 T .default_trigger = "default-on",
: M8 k1 C1 S/ D8 B$ J },: k0 e) B% s" w, {( _. J
};& V2 c& |' `( w, f+ h
) ?$ Z; J \$ R; o ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 b+ h3 v1 t' ^ c) K- N2 K$ ^
.leds = da850_evm_tl_leds,. D7 R; J- k, @; U+ j- M. ]% D" u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 P" ~6 T3 p+ |6 K2 q0 D, q
};) \% ~: H' A# K
. |2 D9 f% y- ~+ @: t, k# Ostatic void led_dev_release(struct device *dev)
2 z! u9 V0 ?5 _- A" P9 s{
8 N$ R& j0 z. S};/ H/ U: g% o8 W% w! r' v: y' o+ ?' ~
, s, r( M: x+ `2 ystatic struct platform_device da850_evm_tl_leds_device = {/ q7 A5 H2 k6 m
.name = "leds-gpio",
' ^) ^% D* e" }- U6 U, u, x) [ .id = 1,9 o6 v8 j' n6 Z- m
.dev = {
1 j/ q7 e9 o. T+ V E .platform_data = &da850_evm_tl_leds_pdata,
0 ^) e* G! ?2 B3 D! U' H .release = led_dev_release,0 ~( v5 k$ x1 m: D
}
: h' ]! K- H6 b9 d};
) z1 A; U% z0 h* |
8 t) M9 [ U' M: {5 jstatic int __init led_platform_init(void)$ K6 G2 L; J1 Y" i& Y1 {6 d
{
+ v- Z6 c/ o6 B1 y0 V4 I {# o8 D( n7 J int ret;) {; _" ]4 F4 ^* `
#if 0
0 l. e2 x$ d. ]2 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 R) g) }% J h2 C6 m+ w2 O
if (ret)
/ Z+ q6 u7 H# A6 X% l4 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( M6 i' L0 x( f8 v- O "%d\n", ret);
( j. Z, r! k4 c5 M+ t$ y( Y V#endif
( o6 s. L6 S% l ret = platform_device_register(&da850_evm_tl_leds_device);- P& f, w" a, Q3 O2 _
if (ret)4 ?& T9 T9 k1 E
pr_warning("Could not register som GPIO expander LEDS");
9 C! V+ W. J6 P6 `; Y- g' Z0 x else
9 M" H1 {# z: i# N6 ?& C- m+ L9 @ printk(KERN_INFO "LED register sucessful!\n");* v1 M5 T6 w' c) i' ^8 f
$ I; t* \% F U6 F5 w" Y6 i
return ret;
* R* Y. R- `0 _) E" v6 U3 J; @' N, n}
% e; m8 I; p6 _; {. c$ ~' z% x
5 A6 _5 w6 J! m: C. F8 e* Fstatic void __exit led_platform_exit(void)
" z4 t3 z& E+ O7 o, o5 q* x" N9 j{
, D, G3 {# H K0 M4 w/ O platform_device_unregister(&da850_evm_tl_leds_device);! B5 o: e, o8 \- |; i8 O% Q
" u0 l7 q7 }0 I8 S
printk(KERN_INFO "LED unregister!\n");
# Z" W- V: m3 d* w}
7 b( g3 c6 Z; I$ q O. u) i. j! D# K3 D4 _( }- k$ j- I; K& Z
module_init(led_platform_init);
4 p, a+ r- T7 ?9 B7 b3 n6 U' Jmodule_exit(led_platform_exit);# E0 O! {- P2 z4 x) E
$ @. V0 R4 B- m' JMODULE_DESCRIPTION("Led platform driver");4 g' L; B7 n, m! n# w ]
MODULE_AUTHOR("Tronlong");
3 [ [7 X5 E4 k8 N sMODULE_LICENSE("GPL");
+ O* P6 e; m' _% Y2 {0 |) r4 y2 ~3 C7 B }
|
|