|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ @, r5 @9 _1 Y5 [#include <linux/init.h>9 I# I5 m( N* s" l) p9 P+ T8 ]; A
#include <linux/module.h>
3 z* a8 l# g F/ \( z4 p#include <linux/kernel.h> s! e/ Y$ ?8 Y* N& i6 B
#include <linux/types.h>( S! q" K' F8 Y5 f
#include <linux/gpio.h>
' L2 _& o; C# B) t# a#include <linux/leds.h>
$ |, r3 B5 e7 d4 w! E. u#include <linux/platform_device.h>
4 k( E! ^" W' q I2 P4 }
9 h9 r% c8 J$ Q# O+ j6 K0 w#include <asm/mach-types.h>
T# f7 R$ a2 N1 g0 c% v#include <asm/mach/arch.h>6 e' m) q# N5 y% L$ g: k5 u+ k( V
#include <mach/da8xx.h># }* v2 f3 z2 j E2 |
#include <mach/mux.h>; x, j5 R( n; z& A) N+ E, a9 J
' [8 C$ a7 D1 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- C+ T9 s( S( M }* a& S6 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ ~4 y$ d, k, ]& @, E7 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& v% m: y- c! T: A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 m5 z* b3 G3 A( ?9 c: \3 X
3 w" V' t; S! u6 s; s
/* assign the tl som board LED-GPIOs*/- a3 F- N1 l# o
static const short da850_evm_tl_user_led_pins[] = {7 |/ b0 T2 C! J; G, ^; D; Z+ P
/* These pins are definition at <mach/mux.h> file */
) B$ F o3 `6 Z# ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ O. h+ u, B7 z) G* f -1 T' I$ m" d1 [
};7 w8 s- I6 n& I4 l4 b
9 S' W7 w' f/ G# X6 o+ v
static struct gpio_led da850_evm_tl_leds[] = {2 P/ M" P X( S) s
{ {5 |4 ^; x+ P3 \6 m9 N
.active_low = 0,
8 n5 o3 ^0 W2 [ m* ` .gpio = DA850_USER_LED0,
8 u8 Z' z& V; ]# M+ s/ A .name = "user_led0",
/ t, L% V; F) i7 u* {, P% h0 S .default_trigger = "default-on",6 M& k, U! R G- [8 Q/ O9 o
},8 C2 H3 O% [; g6 Y: I: z
{
7 C) m i& G: }. r5 E1 X .active_low = 0,
" P$ q5 [8 `9 k0 y# Q" F .gpio = DA850_USER_LED1,
/ q/ B0 j, T) F .name = "user_led1",
2 X/ m, v* U# q& v7 m5 H: _- G9 ^ .default_trigger = "default-on",
' F/ m3 y( p8 W. H( s },
9 ]- `% n m% Z {7 K; S s( g2 q) b" I9 ^
.active_low = 0,
) m# u. L1 t/ q/ g5 w" f) @ .gpio = DA850_USER_LED2,$ {! a& i! w7 d7 q0 N0 W6 y
.name = "user_led2",& {0 S+ K6 E9 d1 y0 o% z. _
.default_trigger = "default-on",0 [1 D4 q# Y2 ~! }7 Z% K7 L
},
/ V& H' G( Z. l: U% } {
/ z0 a+ U3 q" ]6 l: I6 P9 x6 y .active_low = 0,0 T+ p, i- r8 q6 S+ j( l& l
.gpio = DA850_USER_LED3," S7 f5 }# r0 }* e. q% H' p5 o
.name = "user_led3",1 c I) [% M0 K" g( M
.default_trigger = "default-on",
! y/ J$ J# |) C/ A: {9 q$ |* | },
- y7 \4 j( C W) `1 C};
( T) n U$ Q4 B7 B# u) `/ h4 _% ]# P- C. [' `" q8 r% K1 `3 d! ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ H# T3 W4 u6 q3 R .leds = da850_evm_tl_leds,+ f* Z, x0 f& b$ }4 M8 ?8 A6 E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 |1 l" g% f4 N$ R5 R" m};+ ?9 T/ G9 D# ~5 P/ I
) }2 F& t( u, lstatic void led_dev_release(struct device *dev)) @0 t! \4 u0 m6 I) |
{- Y# {2 J" U; e$ \ E2 T2 b- D
};; k) \0 [6 K a0 N0 Y2 m
' `: c* T3 O3 X# [& m& X0 z
static struct platform_device da850_evm_tl_leds_device = {1 v4 \( X4 ^3 A" F
.name = "leds-gpio",8 L5 k/ O% y7 `; Y% w% p+ i
.id = 1, E% c8 O( [ k" p+ }; y- A
.dev = {
. w3 U; D O& i6 B& s6 t7 O3 e .platform_data = &da850_evm_tl_leds_pdata,
+ _; e8 E. F6 |; i .release = led_dev_release,
$ P7 I5 Z8 U/ L% S }
! e6 a$ O' x/ _% ^# z2 g4 I# u2 G* X};% p0 i/ @1 ?5 h
, B- K0 j6 y) N4 D2 |5 F* E- N, l8 J% \static int __init led_platform_init(void)
$ Y! s. s8 ]0 o{
+ b% p4 M! r' R8 M+ {/ w int ret;! Z* J0 q9 e9 ]8 E, ~$ e
#if 0 u' U( T6 u2 e( R- c5 A' Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& a% M8 c2 g! f; ]
if (ret)+ B/ B1 L8 k+ p. R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- Q9 O h F' [ "%d\n", ret);4 ]* b( _/ K6 f, _, T# |
#endif5 q& i7 L; F& I' ]# L# q: U7 r# {
ret = platform_device_register(&da850_evm_tl_leds_device);
+ L3 S9 ]1 }' l/ P5 H/ l if (ret)% Y" |# i" y% x7 W$ {6 ?+ O
pr_warning("Could not register som GPIO expander LEDS");
5 G/ ^, i1 G1 ~/ {* { else. \, B1 {' I& k& ?) s
printk(KERN_INFO "LED register sucessful!\n");
, r" `- K: t' [7 Z$ n, X- o: f6 L# I/ n6 r# o* }
return ret;
# p5 ^$ [, T: K) }3 v' m}
6 Z4 u7 f/ ^9 x" `& h% Q+ O1 K. g% A1 N
static void __exit led_platform_exit(void)& e0 M6 w% ~ W/ A# a: A
{8 n7 c8 s( ]$ Q9 @- W
platform_device_unregister(&da850_evm_tl_leds_device);
q& |, ]6 T0 R- X9 P3 d. I$ p
, @% i/ Q: J( V printk(KERN_INFO "LED unregister!\n");
G k; ^* x2 S9 f}2 ^8 J. X+ b. t( O. Q+ a2 \3 ]8 s
- w2 U! F8 d; j rmodule_init(led_platform_init);
. h8 F3 }$ g0 ` k9 ~/ b! Dmodule_exit(led_platform_exit);
' l- c+ K8 J/ ]0 ^$ G
# c+ J* e) r( YMODULE_DESCRIPTION("Led platform driver");
, w3 A+ s7 R0 s9 N2 j/ RMODULE_AUTHOR("Tronlong");
. m8 R$ L( i y% p) Y# @7 rMODULE_LICENSE("GPL");
: d& _" Y! Z N$ \; J' f9 a8 K7 \5 B# J& _; n
|
|