|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) f* o6 L2 u0 `: { g8 W( d# H
#include <linux/init.h>! j3 j" i+ I& V" n; `; E
#include <linux/module.h>
+ a$ G; T1 @2 l. L2 y s#include <linux/kernel.h>
% p5 a" e( e6 Q W6 O" p: U& t1 T#include <linux/types.h>5 @: A$ I, H) |
#include <linux/gpio.h>
$ u, ]# ]- j" Q. U3 q& g& K#include <linux/leds.h>' d1 F+ l1 J; y' V5 j5 Z* |1 K8 s
#include <linux/platform_device.h>5 ~1 m+ p. r7 \" _3 l' H0 ~/ k
, _: l4 a4 ?4 e6 D#include <asm/mach-types.h>
( G0 ~% i# t/ D+ W/ w8 }#include <asm/mach/arch.h>! ]9 s' N U" c" |0 }* s/ }
#include <mach/da8xx.h>
2 x- p( b6 |% ?" r/ m3 Q#include <mach/mux.h>! V X8 D9 F7 O8 E6 M
) M$ ]8 |, ~) F( V8 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 d8 D9 G9 X( D& x" `* `8 N; O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); s. `2 y8 u; n: G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( W9 @- J7 L7 t( o7 i- P N- ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 W' i7 P" T% k! H" p* V p
$ j) e$ X7 D4 T# ` I% d/* assign the tl som board LED-GPIOs*/
& H( B0 C" c6 q: qstatic const short da850_evm_tl_user_led_pins[] = {
; U, ?" K2 B& ~7 ?$ v6 T2 d( D! _ /* These pins are definition at <mach/mux.h> file */; k* w! S$ Q$ o% e6 Y& \0 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- v& k2 n' ~$ |+ k; ~( V( q -14 U2 z- r9 u+ w# m
};5 x0 W* k' i H. _: p: l
q( B- b+ u Y; ~- W
static struct gpio_led da850_evm_tl_leds[] = {
5 A( c2 G, A2 W/ p; r+ k3 U {
& ?' x% j! L7 C% W& G4 q .active_low = 0,* ?- c) w$ B, p3 W+ H9 i7 H
.gpio = DA850_USER_LED0," V$ ?4 E P* `6 }5 {4 K
.name = "user_led0",$ s7 ]3 C/ \( r& o: K
.default_trigger = "default-on",4 {- s. ~5 O! u* t' j& w
},
- t3 ~8 `6 d R) s {
, R8 n( S T2 m. z0 O5 _! _' Y3 t .active_low = 0,
& `8 U# ?7 m5 J$ C# d .gpio = DA850_USER_LED1,2 G8 k+ J7 d+ S2 ]. f. a- \
.name = "user_led1",+ i) ~+ k; m1 k% Q
.default_trigger = "default-on", c0 q, Z& K* r. W
},
% ~7 x+ K; N4 f {
7 t9 e6 w# A+ V1 w4 Y .active_low = 0,
1 e4 t7 O0 e, m4 k. z9 `3 H2 _ .gpio = DA850_USER_LED2,
4 n% m: B; l+ f& f1 i .name = "user_led2",& a+ J% @$ P# |8 A
.default_trigger = "default-on",
8 {6 v2 I) b0 A7 B1 L* Z& N },! [/ X# A7 q$ F; p
{ w+ z v8 Q6 H
.active_low = 0,
' |% l+ L# w, Y1 M8 ~& Q' ? .gpio = DA850_USER_LED3,
7 }. o+ @# e3 N& |9 l .name = "user_led3",
; i; d8 R' E# F; L .default_trigger = "default-on",7 o. v3 n0 O0 r! x/ |
},
* G1 q0 u& z, Y5 K6 a};% V* m* n% t$ f2 y
7 I g# S, P* Y. m0 qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! @) I1 t! q7 \8 H0 C# g! m" N6 I .leds = da850_evm_tl_leds,: `* |/ c7 \' Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), y# V, J+ t3 [+ K* o0 `
};
7 p/ b+ n K" `$ G6 J1 y9 c B; T- \) L/ j, D! N$ t* C/ l/ f, X
static void led_dev_release(struct device *dev)
2 w8 b( e+ M& a, e{
# Y! ~2 ?6 M$ I7 i( ^6 M( R};
7 L( T, S8 x) ]5 Q9 D9 F+ d! E. E+ I( Q" H H: R4 C
static struct platform_device da850_evm_tl_leds_device = {
, c0 k+ z, S2 b! w [) E7 o4 l .name = "leds-gpio",
; _/ s% k) q2 @* { .id = 1,% c) _! j7 O7 G$ \* J/ @& z
.dev = {% H# k$ M/ e1 ^
.platform_data = &da850_evm_tl_leds_pdata,
" [4 ^% g% f/ C4 i! K .release = led_dev_release,
" f3 j, u: L+ R }1 s- p: N% N. a1 d# P% o$ |
};
b% j) r* X% K/ _, U' K+ w H3 K' w1 A& D
static int __init led_platform_init(void)
- c# R5 F8 P3 g0 C; v{
1 L9 X5 d6 s: z% F! [! t$ E" H2 A int ret;
& m8 l8 m# K4 C C. v6 }#if 0
7 `. F- l' I S/ n* [* @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ w$ _+ r, @" Z0 Y) x, ]% ^ if (ret)0 V+ i' F: o& F0 h" X0 _- H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, l+ r) r! O$ ]* d- ~ "%d\n", ret);" U- k+ q* C/ J- a+ N0 \+ S& B( N
#endif
; o6 {# ~0 L2 K! v* F3 u/ x ret = platform_device_register(&da850_evm_tl_leds_device);0 |' D# V6 T2 o$ ]: O3 n
if (ret)
' g ]% g8 B$ E" Y# v! t pr_warning("Could not register som GPIO expander LEDS");
# c! o% A- K: S3 s! y4 ]! e9 o else
+ ~) A* a. t, X! F7 U/ U printk(KERN_INFO "LED register sucessful!\n");4 B1 [9 v; k, K/ ]- ~' E( d
: t# L" H; X. a- k; { f. @
return ret;, D+ y' l! T1 l8 Q
}
" j) ~8 _4 c% [" o9 Z$ F6 x
( r& e9 w' N9 C/ rstatic void __exit led_platform_exit(void)
$ z. M% Y* I" D& ^; P( ]{
; B# `6 X( i7 h+ [ platform_device_unregister(&da850_evm_tl_leds_device);
% v& j7 V! d" j! r& u5 e j' k# J7 j. l. ]
printk(KERN_INFO "LED unregister!\n");3 x% W5 F& n/ x* K! c& K# q2 e( y
}) z' k% O* n- Y$ `. e( [1 k
; ^6 z3 R* k$ Z" ~# d7 ]# T0 U
module_init(led_platform_init);
/ `5 n* k4 f+ o# Omodule_exit(led_platform_exit);. a) w* ^9 ^ J
- M) X, N! T& k/ ], g; C0 c
MODULE_DESCRIPTION("Led platform driver");
/ N" G( c5 L% C1 }: {! CMODULE_AUTHOR("Tronlong");
; D! m) _8 a b* T) m) xMODULE_LICENSE("GPL");
8 M- c$ A- ^% N: Y' T" n9 A& _9 s! _, [6 U+ b! r( a0 w
|
|