|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: N/ X% C m4 }
#include <linux/init.h>
# O( f' d; v, {0 v# p. [" G#include <linux/module.h>" W# L4 O% b8 a) B
#include <linux/kernel.h>- p- W, S/ U$ j7 S( [+ N/ N7 g/ E
#include <linux/types.h>" l% O; p+ J* s, Q4 x
#include <linux/gpio.h>) V8 ?5 u* G5 T( p, @
#include <linux/leds.h>* n8 Z% U' ?4 X# G* ?/ O k
#include <linux/platform_device.h>; _5 Q( c) K2 L9 L
5 E( m5 z1 i! b: k( Z: h7 T#include <asm/mach-types.h>
3 a) I6 Y5 @# ^5 _; E" d- O#include <asm/mach/arch.h>" w9 q# K+ S) f, i. v5 p4 F
#include <mach/da8xx.h>' y( R4 |+ m1 ]
#include <mach/mux.h>
' L0 T+ J$ [" A) C' M1 D
' ]8 i+ A( l2 w5 S9 X, c" g/ g7 H, H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" P, s2 t' R3 x r" k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 e2 T& _$ y8 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! J/ s: V" L7 m, r3 Z7 l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ `2 L# t& Y% `9 g* N8 ?' |
0 @8 Q; n9 w9 ~2 v
/* assign the tl som board LED-GPIOs*/. N/ y" U+ ] d; `& v$ f
static const short da850_evm_tl_user_led_pins[] = {
# F% @6 I" J9 x2 {; D$ l /* These pins are definition at <mach/mux.h> file */
! H* a4 s* [- P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 j# q9 f. V5 _3 p -1
. F) l( L7 Y8 p. d0 c};
* W; O7 Y7 Y) B, _
0 t! y, Y* ]5 i4 t4 J# Z5 v' lstatic struct gpio_led da850_evm_tl_leds[] = {- g8 Z m6 E: r- S/ h/ j) U+ d1 p
{
' P- `$ _/ J& y `7 B, C .active_low = 0,
7 b* _1 a/ |* C' H7 e .gpio = DA850_USER_LED0,, ~9 d- i- u- `( |, H* A) J
.name = "user_led0",
3 N9 Q; a* @- k4 A .default_trigger = "default-on",( W- M% U$ N0 U; [
},
. u0 K c- d. i$ H8 {0 R {. e6 B* i8 y7 J+ [* c
.active_low = 0,
) ^. s+ t- |5 W9 D .gpio = DA850_USER_LED1,5 l8 |3 @' J8 v
.name = "user_led1",
, m; b. g9 \: Z. n .default_trigger = "default-on",
! V2 W% C! l+ H/ K; \0 s' U },3 L/ O6 V6 I& w& Y. |* L; m* W
{
/ p v3 A+ I7 E: |, m8 h/ W .active_low = 0,
2 u6 O1 V; }' Y* F- z. t T( ` .gpio = DA850_USER_LED2,: {+ X' ^2 _5 c; i, b% g+ k
.name = "user_led2",
) W- m. Y4 F! [ .default_trigger = "default-on",
( Z3 `' T k6 V2 u7 g) d },
" E: _! s: N0 ] {4 E7 {$ H6 Y/ f) r
.active_low = 0,. _) a! f. _( x t& M$ I
.gpio = DA850_USER_LED3, Y: K" t1 v% T7 z
.name = "user_led3",
8 P- h, L8 e, I7 h8 ^! c .default_trigger = "default-on",
( k( s5 L2 F# Y& |1 A },6 F i3 \( L& F q6 A8 U
};
" ~: T4 H, H5 X' ]$ T# [
7 X L$ e7 {4 a' e K: t" a# Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- w0 N( ]7 r! k( B& Y
.leds = da850_evm_tl_leds,
$ X! s( Q m& k! d' |, N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ s- p4 W7 H# V2 S};3 J& L! }: I6 I& i" x* H9 |# _
9 S5 a- B% S0 d3 |6 C7 Y* X
static void led_dev_release(struct device *dev) q) q8 l! i3 w
{
% y7 F& \. e; t( g3 M9 k2 `# p1 H};# M- @. s$ h, d
2 K" _4 p) p/ M) v) lstatic struct platform_device da850_evm_tl_leds_device = {
5 O' f8 f* l$ ^3 ~6 v .name = "leds-gpio",# j) D7 x% ^( G6 q
.id = 1,
V1 j* s0 A0 j2 S. u4 u4 i" a .dev = {! ?) a1 \# q3 W
.platform_data = &da850_evm_tl_leds_pdata,. A+ s+ N$ {) [; q4 S
.release = led_dev_release,* R0 Y+ d& _& u& \1 {0 D
}7 v7 Q+ Z$ L8 e g7 O. y
};* o5 ], x2 w0 O2 g8 u1 I6 K4 L
- D% _. {: W H% c8 {; w5 ^. bstatic int __init led_platform_init(void)
3 y) B" x; T# U7 K{
" }# p. o# t$ \1 f9 n int ret;
0 T) I. `; j5 @7 L0 S#if 0' i. W9 b4 `. j4 _9 R8 U/ B+ _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) Y' P3 b& ]8 c: e; R B/ h" t
if (ret)% }+ p3 T8 @0 k2 W4 Y! `: \$ z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- i( b9 h% B r "%d\n", ret);& q8 T: s: S: V( Z8 A% O
#endif6 o6 P2 ]9 `6 I0 y7 \- I
ret = platform_device_register(&da850_evm_tl_leds_device);
" D1 `4 w: u7 q3 V+ Y if (ret)
) c/ `. Z$ C( h/ l- F0 ~, e# d8 r8 [# m pr_warning("Could not register som GPIO expander LEDS");, Z& \+ W: J( X H9 i' f* l% P) c
else
. {% c& ~2 p* O" a8 \ printk(KERN_INFO "LED register sucessful!\n");6 B6 o! s3 ?1 g- a: g- m$ K
5 |# j# m+ X4 \) T; w! n: [ return ret;2 O* s& s7 t9 K/ h7 f$ V- _
}
- v3 ]9 T) {# C+ {& R6 |" W" o/ k1 b; c& f: M2 M9 l
static void __exit led_platform_exit(void)4 r8 e3 t1 h6 y2 k. M9 v
{; k8 N' I: Q) N0 b
platform_device_unregister(&da850_evm_tl_leds_device);
9 ~; B T! G. M/ i0 w7 c" @4 Z! _) m
printk(KERN_INFO "LED unregister!\n");' [3 P" ^/ Z% L5 J8 q! S
}
' P4 G2 r) g0 q& K' G5 @
, B$ M1 u' p1 l) b" U omodule_init(led_platform_init);+ h- K* y0 _# U9 D
module_exit(led_platform_exit);$ e( @6 m1 I& z1 y( d1 m! \
7 G6 h& N7 X+ D$ I# P3 J- nMODULE_DESCRIPTION("Led platform driver");; U* ^% X8 x1 E2 c- _$ r
MODULE_AUTHOR("Tronlong");6 `) B$ d6 X; w. G2 U" s
MODULE_LICENSE("GPL");7 r2 R3 ^, F0 ?# D3 b
0 w) A% N# z& j( C3 O
|
|