|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' K$ q4 F: a$ ~) I* E#include <linux/init.h>
9 L7 S, a+ `$ \3 ?3 A#include <linux/module.h>1 }; }' Y$ U; }. G" d0 S
#include <linux/kernel.h>4 x0 Q' N( F, }8 y' c5 x
#include <linux/types.h>
9 n' C1 q: y% i- @#include <linux/gpio.h>: n0 l4 H9 R3 M" W. N J
#include <linux/leds.h>
" [1 B- Q0 t* G1 i#include <linux/platform_device.h>
# f$ L6 b% h/ E; h. w
0 I( u: q; d, }* A( j#include <asm/mach-types.h>
) r1 s: ?2 q0 _! x! Q#include <asm/mach/arch.h> V6 j; ?! S. W# e8 q" g* x) A
#include <mach/da8xx.h>5 X! N9 T7 Y, l7 A# |
#include <mach/mux.h>) p* h; K5 y: U4 D& N" `
% m5 W9 H1 W8 J- W; Z' S+ l+ ~2 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 w1 T/ ^0 D- [: l. v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, X. C, a @6 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 y/ Z: t& N9 x* r2 w5 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. A$ I3 N' C# N7 G3 C- ], m6 g) ^$ B; i
/* assign the tl som board LED-GPIOs*/3 k* ]4 O: w7 x# z2 Y
static const short da850_evm_tl_user_led_pins[] = {
( z! L3 x* @0 l9 B: n /* These pins are definition at <mach/mux.h> file */9 w* I5 x( ^2 |+ y1 _: Y9 `" g- q0 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ F/ c7 K( L& F& {- Y
-15 S$ u7 P, c4 K# m
};/ ]2 M0 a" W2 c% s# M F
* F4 Z6 H/ j0 ostatic struct gpio_led da850_evm_tl_leds[] = {+ N% x5 T: l9 Q( N# D* j% [( U" ~2 w
{
3 N/ o& D4 E6 [, V .active_low = 0,' q$ C$ H( J% p# a! ]8 m9 s7 H0 ~
.gpio = DA850_USER_LED0,
) y/ l" J' s B5 I( k) M .name = "user_led0", G7 i( o; A. V/ W- B& d5 q# m
.default_trigger = "default-on",) g; I# s; K# M4 P- M3 L9 R! j
},' n0 b! Y; |& P0 X f; |
{& K2 o* e/ S' X6 @1 o
.active_low = 0,
3 l) r) t# r/ W3 _. p0 x( P) p" i .gpio = DA850_USER_LED1,
# K3 r1 z& D( v! k2 F/ m .name = "user_led1",
! Q1 H5 ]0 }. h! d# s .default_trigger = "default-on",
5 @- P' F* |: U5 D },
8 g8 t8 L, n6 A+ P8 A( b {: }9 ?, g( d5 C
.active_low = 0,3 K9 W, L+ W7 W/ F: ~' \
.gpio = DA850_USER_LED2,- C# L; x0 I: Y9 G% l
.name = "user_led2",
3 e# R6 I1 P# g4 [8 c .default_trigger = "default-on",
5 w e+ s8 J2 N },) D: s3 T6 o# e3 M x0 c
{6 O9 ~+ O3 R8 Z
.active_low = 0,- A. x/ ]$ ]/ u7 | {2 \1 ]
.gpio = DA850_USER_LED3,5 W2 W3 S/ N5 ~ n
.name = "user_led3",: C& K/ t5 g, c! Y' m. z
.default_trigger = "default-on",
' ]9 z9 C! X! Y( }4 G. F) h+ K },
- r( A: B) K! B1 m- v) y6 Z7 Q};8 [* w/ t/ s7 O- r
2 w E9 z8 Y! g! ~" C' lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 O C, v8 E2 Q6 q+ F5 u) A$ Y .leds = da850_evm_tl_leds,* h' v/ W; Q2 g5 x2 v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 _6 Q+ J1 r) R};! `% E" G% m6 g% e# Q2 K1 y
5 f) ~& \3 a y- ?! [8 S
static void led_dev_release(struct device *dev)% J4 r4 p( i- n2 x9 K+ e1 k9 C3 {
{* V/ V$ Q+ v4 a5 H1 b( w+ F
};
6 L) x3 b$ X* q. C# S
7 S& n! [& g' f- b* Qstatic struct platform_device da850_evm_tl_leds_device = {3 f6 @/ P3 r7 d3 N4 W
.name = "leds-gpio",3 I2 R* g; v) \
.id = 1,- h9 b9 p+ D- U" A
.dev = {. o! p1 C" Z! `, u
.platform_data = &da850_evm_tl_leds_pdata,+ P/ v% Z. y" h$ q6 M
.release = led_dev_release,
6 w# a# A; h1 D& Q }
( s/ X, M @$ ?" L0 \' a9 P# O, E/ L};
8 }+ `8 ]9 Q0 @& k F) R% G3 g+ f2 j* ~9 w
static int __init led_platform_init(void)
0 w* @* J$ h7 I+ X& y3 a{; h m& v6 u, \) e4 I
int ret;1 m4 D% S" y; l- C
#if 0
+ @. I0 m& v/ b( R+ a6 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 C0 w5 C5 d1 R/ e7 [ K+ W9 f
if (ret)
( y9 g% y& s: }: w' ~: m3 R) I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% M9 C7 r3 n N" @7 U# e* }% t
"%d\n", ret);
+ [$ {) P5 z& G1 O( t0 A#endif' X, r D2 W* {' ^
ret = platform_device_register(&da850_evm_tl_leds_device);/ P/ W2 L2 K2 I& @
if (ret)
, P/ u7 c! q" F5 A# l- t, L pr_warning("Could not register som GPIO expander LEDS");
9 b$ _ ^% b4 |8 [6 V else3 m$ [; T9 R: J U1 A+ Y3 L
printk(KERN_INFO "LED register sucessful!\n");
! ?- C0 }4 q/ M% M3 x4 _; w) L6 @8 t. X: a$ |: r! I
return ret;
" J* l0 L& f/ F! v}
5 @8 f1 i1 Q1 h( f# v8 }; M6 z
3 G' ~2 T% N7 y" n. xstatic void __exit led_platform_exit(void)
5 s, s% z! j% X6 L( B" A7 d; @{$ }- k: Y, ?& P1 L: d, ?" B
platform_device_unregister(&da850_evm_tl_leds_device);
2 m0 J) F5 i) t2 r+ A3 @5 W) T7 i& y. W# z6 M
printk(KERN_INFO "LED unregister!\n");4 \" b6 a$ z6 q
}
0 w$ Y' b. N" p# L% z$ x5 w
" g& |$ x4 j0 F, F0 q0 |module_init(led_platform_init);2 E* c0 ?! l2 i( y
module_exit(led_platform_exit);
& v7 |6 p" }6 J& E
+ h2 E9 l, L r- i& K: b: k" @MODULE_DESCRIPTION("Led platform driver");0 v2 @0 ?, L2 U$ y
MODULE_AUTHOR("Tronlong");2 `. \: j! r& S P$ R/ ~) f) K0 l- K
MODULE_LICENSE("GPL");+ r" `+ B; L1 x, T: x: i
6 r$ h& M- H0 e! q, N8 V9 P |
|