|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) o& O7 U; j, v7 d#include <linux/init.h>
) { i4 w, F$ b# c- O ?, y#include <linux/module.h>
2 s* X7 h& a: t; R* w; k9 ]! w#include <linux/kernel.h>
2 w2 ?2 b" @- T#include <linux/types.h>/ @ Q7 H3 V6 M$ `- O& O' J
#include <linux/gpio.h>
" m( g0 ]/ g; y* u/ ]7 }( O#include <linux/leds.h>. b y: W; X! V5 u7 p
#include <linux/platform_device.h>
( b5 l- y2 {' x: G9 Y0 G4 T8 x/ k" M$ P1 k; b K& ]
#include <asm/mach-types.h>1 q+ C! S4 s5 F3 G6 l+ G' c
#include <asm/mach/arch.h>1 u8 [* G0 v) V. j$ Q0 u& k+ F
#include <mach/da8xx.h>
" W7 D/ w: V1 i" W: Q# d#include <mach/mux.h>
" Q2 w! B9 ^, J4 D5 [
; }" x) Y7 I2 w/ W/ e! M% y/ w; \7 N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ v3 g! @: b7 y9 ]$ d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) m1 Q3 a2 B0 O9 r* H f1 V6 T [- V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), O* _; U$ m- _2 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" d( i7 Z! t+ U- c6 c% u4 v
6 y0 y9 P6 u3 A3 z" H
/* assign the tl som board LED-GPIOs*/4 j5 Y2 O0 a5 u6 e' h0 h' n
static const short da850_evm_tl_user_led_pins[] = {+ Y0 e% v( \3 C7 S: [
/* These pins are definition at <mach/mux.h> file */
: s# R% H" u7 _ l" X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" d+ I/ m& S" G -10 J# l3 Z8 T$ g8 |1 a' R# n* }5 t' z
};
# I! e+ d" ?) ]6 T
/ {; w- p1 u! I% c% f! W/ ^8 o* ?static struct gpio_led da850_evm_tl_leds[] = {2 {7 P) n' P% s8 l+ X1 n
{
) v7 Y7 v& v0 r) c5 e .active_low = 0,# U# K1 g3 {8 V
.gpio = DA850_USER_LED0,( X! G/ [% w; N3 ~
.name = "user_led0"," {( |7 m- V) G" n
.default_trigger = "default-on",; o! N! i( ^0 x/ Y" ]
},1 [9 k( [; j: D; G% q0 N2 s' O, f
{
( B1 E8 |* c0 t6 B; s2 u2 F2 o# N .active_low = 0,
8 t+ ?% N6 d$ ]3 t# M" r .gpio = DA850_USER_LED1,8 P0 v9 C* E- y- W, V
.name = "user_led1",
& p8 B; r0 [5 ~* H) j- |7 `7 t .default_trigger = "default-on",$ {3 p3 ?! x; w$ N9 U) b
},2 f( `# t, z4 t4 e4 K
{0 X. r- b) W/ v( N
.active_low = 0,9 M: D% c! l4 X
.gpio = DA850_USER_LED2,# K& O9 N0 A0 O7 Q, Z/ H
.name = "user_led2", I9 G N; A x" T& [% V
.default_trigger = "default-on",
8 W) w% a7 l: q+ M7 Y( M- } },
" X3 ?! |2 A. J4 t+ E3 ~. p8 B/ l {
; C$ s. Q6 O0 p' n. i* d .active_low = 0,3 s* x* k7 B. W$ P) H! Y/ L
.gpio = DA850_USER_LED3,: g; D% E1 t! D3 P# [: y
.name = "user_led3",
: ~1 v7 I8 _" ]/ `# b; ~! @ .default_trigger = "default-on",; k8 S1 t( d$ e; j" X7 {
},) m( t, F, i# @8 `+ p/ j
};8 `9 g: U) G4 K: m
& C8 V/ [+ g C M# X( f/ y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 V5 ?# [' m# i5 [# H4 A .leds = da850_evm_tl_leds,
7 n; j! G2 \: p. b& J/ p; U- Q. } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. E, L* o: }# \0 o, B};- N! S& D- ^& d$ ?5 M: `: ~
3 t! |+ U7 I5 e/ V
static void led_dev_release(struct device *dev)
" I- b- E# y' J1 E* ?6 u$ ?/ R{2 T! Q& t+ _3 e' M5 n9 `% \
};
3 o8 k+ s; P+ \. B! P( q! D/ W" K. I
static struct platform_device da850_evm_tl_leds_device = {* K$ y% I+ M* d/ J0 J- K
.name = "leds-gpio",! W- T8 l1 {* |: Q% h
.id = 1," T* F3 I9 o3 k$ J
.dev = {2 T g) g$ P8 R6 ~8 D8 g
.platform_data = &da850_evm_tl_leds_pdata,* Y& P3 n0 ~+ c- d
.release = led_dev_release,
2 ^( d, \" E4 M0 @- r2 N }; W# Q1 o- k1 ~/ B3 E |: D& Y
};. U9 l4 a! b" l) S# ^( W1 V/ ^6 Q; j
: {$ H5 ~6 d+ w/ I* istatic int __init led_platform_init(void)6 E3 f+ o5 W4 ]! i1 Z; n1 \" s, b/ [
{, @6 J6 B6 g) \& B6 A+ p; r& V" Y
int ret;1 S: K3 f: R' K) m+ u2 |
#if 07 z C& `4 J/ t3 C5 G3 E5 d7 X& m1 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( Z$ @ ]2 G ~' B1 s% E) s( ]
if (ret)
; N4 ?# y6 C5 o6 v0 Y; h: } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 F7 g8 r! V' H" t3 n "%d\n", ret);" P! H+ C, G" J
#endif
4 {6 c( [& b6 U ret = platform_device_register(&da850_evm_tl_leds_device);5 Q5 R0 [3 `) Q1 V
if (ret)
/ \5 | H. a/ J' W- ?0 w' n& d8 e pr_warning("Could not register som GPIO expander LEDS");7 v$ N: g8 o7 W) r7 y' H) s/ a
else8 S9 ]8 `1 r: ~% l) ? }
printk(KERN_INFO "LED register sucessful!\n");& M0 d5 Y/ S3 O: ~, y. M
% k \; u- ?2 S7 f return ret;
7 v3 r$ r: C4 _0 Y# p}
# W5 F! }. H+ G2 o
! w4 _( ~9 H& P7 f8 f* ~3 Astatic void __exit led_platform_exit(void)$ E- I+ K# b/ U ] x3 q
{
2 O O. D; I d! G platform_device_unregister(&da850_evm_tl_leds_device);
4 s- W, t5 G2 _ x
- p8 G9 Y7 }9 m. E, i8 U printk(KERN_INFO "LED unregister!\n");# ^$ K9 a h7 N, M$ k' Q& F
}
* R0 Q" Z8 k8 h; D4 Y7 h/ |# ]- {
: E# R! D# i, V/ k: D/ c5 _% Q: L. Tmodule_init(led_platform_init);
* H6 x$ d4 O0 ymodule_exit(led_platform_exit);
$ G! P" ?( z9 I6 j1 \: p5 y$ W& Z6 M* v4 o. O5 P
MODULE_DESCRIPTION("Led platform driver");6 Y2 U% l) N( i- g* T6 e1 J
MODULE_AUTHOR("Tronlong");
: s8 T$ N3 Q8 g7 o) O4 UMODULE_LICENSE("GPL");
- T* E- `2 b( [( T4 P/ z. S# P. C8 A/ Q
|
|