|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. A& E: S0 ^* s( \" N- U#include <linux/init.h>* i1 B3 `4 b4 y9 F" e& A( D7 z
#include <linux/module.h>* k, h' N; V: c2 u1 b3 K- j/ J
#include <linux/kernel.h>) D. p/ {9 M, z }2 [; q E
#include <linux/types.h>
5 w* J! f) x: A7 k& ]; F F) o E#include <linux/gpio.h>% T7 J7 M4 }* r. l7 o5 ?6 E+ X
#include <linux/leds.h>
" q2 E. @0 V% D: c t" q3 V" ~% c#include <linux/platform_device.h>& D9 U, H% @5 \ I( x
* b9 u( ^( B$ |# {8 a# K#include <asm/mach-types.h>! J1 R$ O( c( h
#include <asm/mach/arch.h>
* r m B' j) e6 w! t U#include <mach/da8xx.h>) Y2 L& [# P* q( @
#include <mach/mux.h>
1 X; J- K* w% o$ |( r0 E! m: M. l# E8 p% p+ Z, t' \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) N) o" ]; O7 G5 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" q# B6 V( a$ Q) L7 O5 p/ w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ Z2 ^& q& d2 m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* U* x" z ~6 V0 G7 C& o7 U% J- i, q
/* assign the tl som board LED-GPIOs*/$ u: y* D1 n2 W% O
static const short da850_evm_tl_user_led_pins[] = {
" Q: b1 t R) R) s4 b( ?: r /* These pins are definition at <mach/mux.h> file */" c/ K1 k7 P2 a( ^; ~) G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
o) a$ m" Z5 [# b4 M5 m- `. Y' |) |- L -1
) V* F: }( U$ V" h8 m V! i; o};
! R2 v9 o ]2 X# K) R
6 ~, ?7 G Q$ z& [static struct gpio_led da850_evm_tl_leds[] = {
; D1 `+ @9 R: m4 h {' o U. M s" }! E+ O! \
.active_low = 0,2 I1 Y7 i* W+ y8 R) W. v3 d% W* K' ~
.gpio = DA850_USER_LED0,3 ]0 C- x8 M( z# U8 V
.name = "user_led0",
) F* W$ P9 \3 p% X1 n- _ .default_trigger = "default-on",. ]: m- t! C: c, c& W! t
},5 N4 S; _: `% N w" r
{
. y% o# G/ |$ q( L .active_low = 0,
. H" [ Y& B8 c" t8 h8 u .gpio = DA850_USER_LED1,
" D0 `( a- P6 \9 ^+ a2 H .name = "user_led1",
1 a0 k( g0 q6 \/ j, y .default_trigger = "default-on",
( H0 l' W1 l$ j0 N7 \; n# W. H8 G3 `9 ^- ~, F },# u" K+ N/ X+ r: r
{
# s2 P# a. S' L8 e8 |1 i: P .active_low = 0,
. |8 f' d4 {( d2 m& f/ h1 C% ]- D .gpio = DA850_USER_LED2,3 c+ x3 h) [5 r: a! O- g0 `
.name = "user_led2",! p$ l- A( R8 Y: x$ A1 r* d
.default_trigger = "default-on",& F2 F6 }$ L7 P8 |+ s+ T$ E* m* s B
},
8 ?6 i2 B7 ^3 X {0 F0 F+ J7 b& L7 N$ \( Q
.active_low = 0,/ `* P! L- I. d. |2 E
.gpio = DA850_USER_LED3," E+ o7 v R" y
.name = "user_led3",# g; S+ F0 L$ D4 P6 [" e
.default_trigger = "default-on",+ d8 |, ? e. k( I. d! z
},
# Z8 `+ d0 O- M* Q6 E- K* s: s};* ?+ ?( f, B6 L+ q, x
. T: e$ t2 \/ k: S4 ?% Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( w" k( g0 D7 b: c .leds = da850_evm_tl_leds,
; O) M) r4 N' K' J% b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 [" l' {. b$ N2 z- ^}; |2 r8 S4 W" A& a0 o! O* O5 r% N3 T
' h: ?% s1 x- Q4 A% O2 g0 i. V
static void led_dev_release(struct device *dev)
7 U8 k% H* d# m7 P, @{+ F6 X' p' [6 G
};
7 g7 B: p1 H( _
9 i# L) g" c6 a# n0 ^static struct platform_device da850_evm_tl_leds_device = {
/ }. ]4 O/ L9 M7 \, S2 O4 s4 [ .name = "leds-gpio",
1 T' R. s! P7 p+ p: ^/ v .id = 1,/ f* m) B, q/ |2 ^' _1 B) ?& U: a
.dev = {
$ a/ A) b/ u. |, |/ f7 G .platform_data = &da850_evm_tl_leds_pdata,
- \/ |" G; }- A .release = led_dev_release,, E9 t: j" s; y& r3 B
}
, p5 H/ m: U* v$ Z- ~9 h! i; R};# n( ]* _: w t& F$ }- g
9 G$ r/ \1 P. {$ H, m0 D) m4 K
static int __init led_platform_init(void)
( d9 e; {* f/ {' X. k4 h$ I{) m. b0 U7 T( E7 M* a
int ret;$ f7 ]% k$ B% H$ m# `" O3 D! t! X
#if 02 B" ^8 Z, w+ s- @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 }. e7 b5 ^3 o8 P2 J9 M1 @
if (ret)5 I5 W/ ~' d; C3 [! D; P1 F' n* ^! X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 d. ^0 {5 z4 [. c* q4 r
"%d\n", ret);4 z6 n/ B% K3 v' Q5 H+ G
#endif
2 b& N9 @' C: z9 {* Z/ Q ret = platform_device_register(&da850_evm_tl_leds_device);
?! R& E0 P. ] if (ret)* t4 o' `& t ^1 l
pr_warning("Could not register som GPIO expander LEDS");
+ H5 _: j' Y* T& }: n else! @$ u( i" ]/ W- ~* l+ ]: t
printk(KERN_INFO "LED register sucessful!\n");/ P+ x" C# g6 o* i: D( c4 d
W: w8 J3 L) L2 H% T1 C9 t! G return ret;
/ A( |) {0 Y( @: N$ V3 n}- i ~4 Y# a% R0 A# T: U
' m( x, C# s/ F- Dstatic void __exit led_platform_exit(void)# ^, q8 V: d6 E* T3 ]9 L
{
: w. f9 J. B1 h$ }- y platform_device_unregister(&da850_evm_tl_leds_device);1 D+ R; r1 t" g( B3 P
9 N" B2 n* Y& G$ {
printk(KERN_INFO "LED unregister!\n");
1 q) y: F0 K" P}
# G6 c* H, r: h* U R% v
0 l. |$ D8 H; y5 J9 u1 Z, P. |module_init(led_platform_init);8 G. P# S: U$ ~# W
module_exit(led_platform_exit);
1 l2 l* N7 m* I8 X J/ h4 b6 o* J+ U& G
MODULE_DESCRIPTION("Led platform driver");
: Z2 A) i6 A `MODULE_AUTHOR("Tronlong");% X. z9 b. t- A
MODULE_LICENSE("GPL");" _; W* j1 C* s$ n
) h# s8 p! F/ _: X( P
|
|