|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
e- E e! j1 T2 T: Z6 l#include <linux/init.h>: `0 x) B' u2 b, }2 C V) I- _
#include <linux/module.h>" f& C4 D8 D: S
#include <linux/kernel.h>
1 B0 U! @$ Z7 z6 ?$ l#include <linux/types.h>
8 \1 Y, O' d/ G$ v5 {2 f+ u$ ~8 x( m#include <linux/gpio.h>& W5 F" A* {9 L+ `7 K6 o# `1 e
#include <linux/leds.h>% N* B% S* v" A) C) y
#include <linux/platform_device.h> s2 z6 J" n9 P8 f' r, c( q2 F5 j
8 t) m+ t: e5 L X- r$ n" X, d
#include <asm/mach-types.h>
& ?( |: w/ v1 W- U8 L: {. n4 x( }#include <asm/mach/arch.h>
. b4 w% N: c6 X, y( D. r; g b#include <mach/da8xx.h>
* I0 n4 O; k% K$ h#include <mach/mux.h>* g/ E& k) j: ^, n* C: H
4 H/ W+ N' [, f1 M: `8 y$ K9 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), O) _) c9 V" ^$ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) L1 h5 ]7 k! Z/ @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! r3 F* m: F8 }9 J9 p: ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 |4 d- j: K4 R% T* d9 \$ i; b" ?. P1 Z7 D* K# B' v
/* assign the tl som board LED-GPIOs*/
& _- Y( w3 u, n& ustatic const short da850_evm_tl_user_led_pins[] = {. `1 k3 V7 |5 t% s+ Q' ]
/* These pins are definition at <mach/mux.h> file */
e# z: ~( c6 g$ C( F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& Y9 H% D6 K; f' o$ u3 B& A
-19 I4 S' |' O* p
};
. A9 Y0 I. t1 Z
( X9 H3 b( y' V; }0 f7 w' |0 K7 Kstatic struct gpio_led da850_evm_tl_leds[] = {
; v7 K S) U, S8 p. ^8 F* {* ?: C {
. i3 T8 t3 M6 S2 y+ P- M2 s! A% W7 a .active_low = 0,1 P R% b2 `$ M3 p$ E9 ]4 W
.gpio = DA850_USER_LED0,- H# O, j" g4 S. b/ V! z) s% ~" {
.name = "user_led0",+ P- V$ M1 v0 j$ _4 z9 M
.default_trigger = "default-on",% x: C( w) }8 c8 s1 v. q; g
},1 x0 }# k7 U% Y% w# Y0 ~
{
1 ^; g) Y: w# Q2 t8 X n" B9 {: Q .active_low = 0,
1 u% p6 H' N! w# C1 Y( F% g- A .gpio = DA850_USER_LED1,
- r# b( F4 i0 O, j9 q0 m/ S .name = "user_led1",
. m* R3 c6 ?+ z- S+ G% b .default_trigger = "default-on",- G7 R: i) ]* L6 c% I
},
# C$ x, ~( a R5 e% ` {
+ A# c: m% u+ X" ?7 D2 R/ O .active_low = 0,
' l7 @ ~6 ]( E" h: M .gpio = DA850_USER_LED2,5 m8 R, C+ Q5 [; w/ S
.name = "user_led2",
5 }$ V$ J! E; s$ s3 x/ O. R; M .default_trigger = "default-on",
& g. V Q) k, ] },7 T3 \3 ]: }3 c& {6 g
{0 y- y, _: z$ x# x, |
.active_low = 0,
& I7 B: U2 s& i2 G .gpio = DA850_USER_LED3,
, A$ ~9 ]2 w% q" B .name = "user_led3",2 }/ s" k6 [- W% ^# S f7 _% i
.default_trigger = "default-on",
: H" C( r: h5 ` },- g( P/ V0 G# V. \8 I
};3 x# |) w" o: G* N. W- d
8 p% Z! I! K4 `- z- j5 y& V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& z' v) h$ b1 ^; o; a A
.leds = da850_evm_tl_leds,
, z, r# v5 _; N& ]# T! o" z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 l$ G7 U S. F};
4 T0 J( Y5 y2 w% a8 j7 }( u7 d" L
static void led_dev_release(struct device *dev)
% E$ A& X4 u* q9 N* j{& @2 z; n E B& B* N |1 v6 j/ r
};
9 Z6 r) A& o2 i, m5 d, W
& e2 G" s+ D7 ~6 B" [static struct platform_device da850_evm_tl_leds_device = {
& o/ V* V7 z2 [: Z .name = "leds-gpio",. {# s& L0 o3 f+ ^
.id = 1,
2 i& I- j: u% x/ A( E .dev = {
& H% l* r* P0 I* M6 S3 \! b .platform_data = &da850_evm_tl_leds_pdata,
& _6 ~/ [$ _8 { .release = led_dev_release,
; D% r6 E9 k8 S. ~ }+ Z* B6 I) E/ L( u- T/ k4 T, U
};) u1 w3 u+ q( x7 j7 z; a
+ P" f3 {/ e% P: W% }
static int __init led_platform_init(void)" J5 |2 n+ m* m" a: L; S
{
) t x1 ]* f' Q! ]& T# p* B int ret;
! N d8 [% P. X# c8 Y9 E6 e#if 0 C) x+ D K% e: x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% {5 Z t E% s x/ h; s0 e, Z7 X if (ret)% L/ Q1 H$ |6 b' R# r0 l+ S+ g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# Z+ o3 O) n8 v% t
"%d\n", ret);
4 H3 D2 J0 R. s0 h3 ~6 j#endif
3 {9 f- R7 ?7 o ret = platform_device_register(&da850_evm_tl_leds_device);' P- N5 f7 y H
if (ret)
1 v N9 d- X( z! ] pr_warning("Could not register som GPIO expander LEDS");5 p& A! m2 I D( C
else0 o3 V: m$ }8 \4 M
printk(KERN_INFO "LED register sucessful!\n");
" d3 A$ t% o! P }7 h; S/ o2 y h, V' j# w1 I3 P
return ret;2 w, f8 I7 x3 @5 Z3 |) ?! ^5 q. x
}
; b5 |& ~8 I/ H. y; w, i2 S% {2 X, {3 l/ |5 {( i9 j5 O: J7 z* R
static void __exit led_platform_exit(void)
$ \ v. Y1 V% Q* e% U* |{
: u% h/ ]6 X* G: {( ]; } platform_device_unregister(&da850_evm_tl_leds_device);
6 `- S8 \0 k) E T& U+ Y; X$ V* \# N, S& i% L5 D, n
printk(KERN_INFO "LED unregister!\n");: n) v' y3 }/ B5 G: b5 W' ]+ \
}
$ d0 y, H6 b# i0 b$ [9 K" d9 ]* B9 B: z' O
module_init(led_platform_init);
% y! z2 X: g" emodule_exit(led_platform_exit);3 ~: P: A$ m2 m, R [) f
# P% y: c8 G5 \5 i- y+ O
MODULE_DESCRIPTION("Led platform driver");
8 ~) X4 z: |1 |" e) JMODULE_AUTHOR("Tronlong");
' k& G9 f* L( |- h- S' RMODULE_LICENSE("GPL");
- V! T: G& N, g4 s9 K7 `8 n) Z7 {( {. z1 r2 E, P
|
|