|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 K% K' { H r1 {" G& V
#include <linux/init.h>& Y% [/ z7 e3 ~/ ^; d
#include <linux/module.h> t( S5 o6 Y! g- q: o
#include <linux/kernel.h>
% m" L0 [6 k, B; N7 ]6 V#include <linux/types.h>
+ w- a& v' e! }; V) T3 a0 X#include <linux/gpio.h>
9 c+ \+ o- u" d' {2 {#include <linux/leds.h>
4 c4 X: H5 k. M1 S#include <linux/platform_device.h>, O, ^- F/ l5 L3 H9 h3 v0 N
; G& U' l5 U1 |
#include <asm/mach-types.h> g& A- w$ |# v) ^4 j
#include <asm/mach/arch.h>) _; F3 ?/ {4 L4 m3 p
#include <mach/da8xx.h>
: U, O I2 Z# }& h7 \#include <mach/mux.h> t: O" O1 H# z7 A
! r ?/ @! U8 y. S/ Z( [- n, A6 ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 s1 j" _: {- K5 @/ S6 A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& `! ]1 B6 O# {" R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ }( ]8 N& C/ z! z- ~- I; B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ @. Z7 z: F. n r2 h/ @! s% c2 z, d1 C+ X! a$ _: X
/* assign the tl som board LED-GPIOs*/4 ^2 \, ?6 _; [' V
static const short da850_evm_tl_user_led_pins[] = {( _ J+ y! j+ X( _: D5 a
/* These pins are definition at <mach/mux.h> file */& x; `2 y8 D4 g. C. q4 ~2 `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 H! f/ s7 d* V7 V: a
-1
! T; N' r! N( X. Y};0 o/ h9 ^+ P* Z7 n
* w/ ]( b. l& R$ T/ t
static struct gpio_led da850_evm_tl_leds[] = {
- N$ i5 Z+ T; e" {% V2 L {
* p/ r* \" w' f8 H% \/ u .active_low = 0,
9 ^; ]+ L5 w- w' U4 t; V( r: ` .gpio = DA850_USER_LED0,
4 s9 \* X- j+ V .name = "user_led0",
# ?) m% `2 B+ \' F .default_trigger = "default-on",3 m* w# }" c+ B! V2 ~0 \; M) X
},
7 r; Z7 _2 J; G0 V) b {; H- N2 u' {& P7 R! p8 V4 \& Z
.active_low = 0,
( D3 ~! `0 S+ b5 O# S( z$ W .gpio = DA850_USER_LED1,, }# A( A& m+ z6 t% @% l2 B
.name = "user_led1",
( L& U1 h4 a0 S" ` .default_trigger = "default-on",
/ L7 o( I' s$ y },9 O# f9 c/ L/ m9 D% j; _
{
! W3 I6 u/ j# F8 o+ V) n& _ .active_low = 0,3 V: x8 s* O2 V) S+ \1 ?+ C
.gpio = DA850_USER_LED2,
& _ Y9 `; p0 z4 p' k$ F- ^ .name = "user_led2",
4 n i6 c/ w. M! r9 l/ j8 l .default_trigger = "default-on",
! t+ m; z! s& r },& ?" W6 j/ O7 K( J: J+ N
{
7 w1 F* Z2 r7 H5 U .active_low = 0,1 \% m/ X& f! T- e' m5 J
.gpio = DA850_USER_LED3,1 X0 h. b( R0 W2 w( T& j; a
.name = "user_led3",! } A8 d! K$ }4 I1 d, A0 E/ a
.default_trigger = "default-on",7 t) V( M- X4 z* P7 _
},
. t3 r( p+ r5 p+ O6 N u$ @) U/ l/ f};4 N, U. ]: M( V# }, A0 h
- T& P6 A- u: C2 ?# G9 M* ^9 sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. o% V0 r6 |4 T; ~' m .leds = da850_evm_tl_leds,
0 R0 g+ ?2 x. [) v1 E2 Q5 H. i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ ^3 t% }3 {5 N7 y1 ~+ [* N};- a2 g1 w3 h* e8 [' p3 M0 N5 s/ I- B
0 x$ H0 _; E/ f2 W9 n. O* M4 t- X: K% Mstatic void led_dev_release(struct device *dev)
+ |8 @. T2 z& C7 V% V# y{
) g+ _' K" \) M" ]$ ]/ q( L$ U# s. V};3 t# s% X- g7 `* c" _5 b4 C& B" R x
1 Q* b, e; N" H3 Z: F1 gstatic struct platform_device da850_evm_tl_leds_device = {4 s: ]9 |" M9 U7 Z" Z0 i) x9 w
.name = "leds-gpio",
X7 a; W* i3 o7 B, ] .id = 1,
7 p% j5 I4 ^% \- z( I .dev = {
6 z4 `( U* m5 u+ S .platform_data = &da850_evm_tl_leds_pdata,
0 T+ m# e. @0 q1 B$ P* o9 ]6 K .release = led_dev_release,& p% |1 K. i; {# o) y2 D6 y
}: V7 j' M9 |' W/ q1 B: C6 i- c d
};" w2 A; W# K3 x3 R7 {% }- }, H" j
# T7 c+ C" z+ O0 hstatic int __init led_platform_init(void)' ^9 J; [+ {0 I
{2 T$ P' Y) S) n1 |& j7 p; y' B3 z
int ret;
+ u/ \+ H: {$ s. e7 Q#if 0
; ^2 Q, r4 s+ ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); s( ^ I; Y% g I9 _8 Y
if (ret)
, b( K1 P: b% V7 B: {2 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. b7 a1 f8 n& ^0 c/ g9 l% ` "%d\n", ret);
; M% v( G- b9 f#endif
2 V; i1 f% H/ B ret = platform_device_register(&da850_evm_tl_leds_device);* d( S6 J2 {! F X5 ^/ b
if (ret)1 h, z0 F0 |2 o: c; h$ u/ H a7 ^
pr_warning("Could not register som GPIO expander LEDS");
# W# a2 M5 {$ w9 P, j else
4 a" p* }1 {0 j" k8 R( U printk(KERN_INFO "LED register sucessful!\n");- k* ~5 Q' O9 u
1 |' U; L+ z9 G. \2 E& x9 a
return ret;
% H; D* W; @$ ~* r7 t% b N}
) F9 l5 V5 Q- e6 j2 V
9 k( E. }- `0 R- m5 `static void __exit led_platform_exit(void)( R" V* ~6 i2 p U! e- p$ |( g3 N
{8 s! w4 g6 x+ J% E
platform_device_unregister(&da850_evm_tl_leds_device);
) n$ E0 M+ Q; F: F$ p' V
+ u) Z9 Z! Y, C2 A3 v9 | printk(KERN_INFO "LED unregister!\n");6 J1 m" J ^& O2 ?( b
}4 R- W, d: H) W8 w( C
; u4 @0 Y5 }, p) @ L: _2 @module_init(led_platform_init);0 G* U, q, e& t/ h
module_exit(led_platform_exit);9 l. a1 K, n }+ ^8 A
9 F: }7 R8 Z+ U; f6 ^, f* W
MODULE_DESCRIPTION("Led platform driver");9 E1 F* _# f1 j6 `
MODULE_AUTHOR("Tronlong");
. R4 Z% G, m Q, F! M. pMODULE_LICENSE("GPL");/ G+ p X% I& w; C) o
! u7 }/ x+ `2 _( G Y% x! K: ^! x/ ] |
|