|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 A0 k7 _% x* N! r& p8 N#include <linux/init.h>! M( o! ^4 H3 W1 ^+ P
#include <linux/module.h>
. Z$ N( H- J* y( P9 t: `% u#include <linux/kernel.h>, b4 O- k% K% X4 G8 Z/ u4 l
#include <linux/types.h>
8 w: ~4 q' z7 W9 o* U9 F' M#include <linux/gpio.h>) f1 E1 V t" h2 v6 K
#include <linux/leds.h>: U8 V+ X( ?0 k! _+ j; w3 Q% ?
#include <linux/platform_device.h>
& P1 ^- S9 [) l2 C$ L4 o9 p, O6 d7 g# g6 e7 M0 I4 K( o: v3 V
#include <asm/mach-types.h>
0 l- l6 \1 P0 l; Q8 w4 P7 b#include <asm/mach/arch.h>
* a1 n6 x& j7 q" K- A. m9 q! R#include <mach/da8xx.h>
" ]: Q t$ F3 o, m" _+ a$ m#include <mach/mux.h>
( k4 G' J( t& i# ?& H0 O3 D. a% h
" v1 @+ C1 n' G8 q# p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): v2 }! i p! G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 E4 C1 e$ t- U6 r' J" a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 W7 p8 f2 @7 ] F2 s r Q" n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ M' h. r( g9 }9 x; j, R
4 u0 V* v# b# c, V6 |
/* assign the tl som board LED-GPIOs*/
& [: q; |, T9 @4 e, ^static const short da850_evm_tl_user_led_pins[] = {
9 b+ w( D0 s# J8 ?! j /* These pins are definition at <mach/mux.h> file */
4 c" x: S6 L9 R. i+ ]- ?2 G& ^/ Y7 m) W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 o$ V; q0 m8 F+ N$ F! k; e6 v1 @; G -1
" c' c6 l# U: Y2 ~4 S$ n};
6 B! g1 t8 i& z& w4 s/ Z. I, i1 a8 F2 @& X
static struct gpio_led da850_evm_tl_leds[] = {$ J. c: i" o6 V) s, d/ ^7 c. Q
{
" z0 f! f7 G! @# C" L3 y. p' e1 R: a .active_low = 0,
. x9 r. b' j; P .gpio = DA850_USER_LED0,# F* x* ]0 e& w! T) h2 L% W
.name = "user_led0",
, s. U7 _- i5 T: s; L .default_trigger = "default-on",* e0 o% |3 Q" W" O
},8 }5 W4 M: l3 u8 x! @: q
{$ m% U; ]/ q+ | h# ]) o6 ?
.active_low = 0,
/ Z, M$ l% V% [8 Q- V .gpio = DA850_USER_LED1,) C* }4 W5 j8 E- A- d, X& _
.name = "user_led1",& f* M. u$ P8 S. o, K
.default_trigger = "default-on",
; M6 v3 f M1 t+ C },0 m- |7 k1 G# w
{
% b t5 `0 ^0 T5 B .active_low = 0,
& k W: E1 q2 y0 W .gpio = DA850_USER_LED2,; [. _4 Z* f+ j! L; R6 G( {
.name = "user_led2",
. \ d" g5 F4 Z+ l .default_trigger = "default-on",
/ {$ @7 H0 j; m' l, F" r },
M) ~3 H, o7 p7 j* { {
, P6 ^8 a5 H' X .active_low = 0, X* d/ u/ G4 X0 C# I6 Y% o
.gpio = DA850_USER_LED3,
* `- c. u% t! a) k M3 j .name = "user_led3",
3 e m; @% k+ c3 S- x .default_trigger = "default-on",
. t' T \. j h- u. L6 b3 @ },3 Y5 X8 v. ?" j$ F- j) d8 m" j
};7 b7 s1 Y; O! p& s( O
, v& X j2 ?$ s- y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ }6 q \) y; k c' F9 P2 Y% k .leds = da850_evm_tl_leds,
, v4 {& |& |0 H, |6 `$ n3 B7 S: r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 r* v/ o0 r% b! Y$ e& T
};
3 E% N9 _ C' c. A
( G) H) J. j1 q: wstatic void led_dev_release(struct device *dev)& U3 m) \0 V% u6 B% ~1 C L
{7 P, x7 i7 k! C% O9 V. m
};
, u/ g2 ?* F/ t" M* h& F! p" _( x9 B$ v& |7 t
static struct platform_device da850_evm_tl_leds_device = {+ N5 M2 }# Z+ }, c; c
.name = "leds-gpio",/ s7 l4 b; k5 O1 j3 n% }
.id = 1,1 x6 m/ F/ A0 c0 \) U
.dev = {
4 s- U8 J* C2 z* D2 t, h+ K .platform_data = &da850_evm_tl_leds_pdata,3 Q& F t( G* }0 P. F
.release = led_dev_release,
2 R1 K0 h1 e4 |+ J, J. U. ?) t }1 P' R- {" m, g: |( }6 C: g& \
};1 P) F, Q% a8 f
3 ]* X" q$ `; o$ h" z
static int __init led_platform_init(void)
) Z- J ~ A Z( C* f$ F{7 l2 \. {& B( c3 }+ f+ ^0 j
int ret;
* e0 d& h# B4 s" @" C0 I3 F& S6 ^4 x, X8 m#if 0
$ e0 G' [: C U: g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ z3 Y% u. s {) T0 w" A
if (ret) u8 k0 l9 Z3 u4 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ J. } B- u q) a3 I "%d\n", ret);
+ d. n% V; |$ O#endif
6 Q# B6 i+ b( ~, H0 B! W ret = platform_device_register(&da850_evm_tl_leds_device);
( n1 A8 M) f5 m# i8 s$ _/ b if (ret)
7 G8 H/ B" J {% q8 y" z# ^5 \/ a pr_warning("Could not register som GPIO expander LEDS");
! U! h1 u# T& N$ A+ }( s! ] else
, H) { m* E4 T( ]9 { printk(KERN_INFO "LED register sucessful!\n");/ g- f$ Z9 W3 X+ X8 b( r
6 u- i, u/ J+ y3 u4 b) w return ret;. T( w! l3 s6 M
}
, O! I* \! ]! y/ C7 l& [
( c" B! B, U, Bstatic void __exit led_platform_exit(void)
! ~$ \ k) h$ @5 t+ Y Z. d{/ F! s5 O7 ^6 y9 o& O. Z
platform_device_unregister(&da850_evm_tl_leds_device);# i+ y e; Q3 d$ K
7 W' s) r, `8 e. x( }
printk(KERN_INFO "LED unregister!\n");$ g" c3 \2 \% r2 c) r6 f
}8 d, C* Y0 I4 a9 t4 f/ l
; A5 k% P' f6 |6 Z* Kmodule_init(led_platform_init);
! L ?" ^4 l* F* h! x: x$ jmodule_exit(led_platform_exit);: h4 r1 z! t0 R! N, g
/ T5 c3 u! w- v1 h
MODULE_DESCRIPTION("Led platform driver");5 h+ v8 _# _: B4 v5 g0 w# M- H
MODULE_AUTHOR("Tronlong");/ }+ y6 k' Y' W4 R9 [# _
MODULE_LICENSE("GPL");. j" ^0 |+ o' j- B; H6 W; u3 p4 X7 h
0 t# X! e6 I, [0 |, |) m |
|