|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ C" t, k( y3 \3 L5 G' I' C/ z$ F% q
#include <linux/init.h>
- ?/ J' [4 E5 ~# u! w. u3 V o% I! ?#include <linux/module.h>* t m6 o( |, T
#include <linux/kernel.h>
- c- L2 T# L1 R$ G, q9 Y R#include <linux/types.h>
% c$ {4 @- y) _5 q/ L. i* n#include <linux/gpio.h>" G; N! s6 X* f6 ~' y
#include <linux/leds.h>
! g# r9 D0 g s ?) p#include <linux/platform_device.h>
% n% `/ ^9 v9 _# N
8 s* C7 E2 j3 W1 ^; O; l. C#include <asm/mach-types.h>" S% B8 u% U- T
#include <asm/mach/arch.h>) a, |# l8 o3 X4 S! w
#include <mach/da8xx.h>" ^; R& S" a; @
#include <mach/mux.h>
& G8 B* ]& k6 Q0 O& c
1 g1 q k; }" q% r1 s1 \, c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
]9 R" u+ ^' e, E! u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& f5 o$ }$ _ D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- v3 l7 W9 K- d- X( l0 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% w% ~$ w3 |- N* K) r7 @$ P$ G
) x* w# K7 U& M8 u3 m0 l0 R/* assign the tl som board LED-GPIOs*/% K9 x4 ~+ \' _$ ]1 W
static const short da850_evm_tl_user_led_pins[] = {& O4 G5 q: _7 `
/* These pins are definition at <mach/mux.h> file */) P% o3 \6 T+ S9 I4 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 |& L5 B7 k' f/ o2 P
-1
4 ]& F) j( }& }# p};
6 ]7 F- q/ O8 `% c, W! g: G" K% F1 g3 M
static struct gpio_led da850_evm_tl_leds[] = {
0 Z5 U* A$ s0 w5 U2 _$ G8 ] {8 Z. T3 O& j' G u$ U
.active_low = 0,* D7 T1 l1 n; }. m% n! X9 T
.gpio = DA850_USER_LED0, n! P; H% n5 c! I! ^
.name = "user_led0",
+ u+ h* E$ `% l% q .default_trigger = "default-on"," a, S+ ?. L/ n) H, u) ]5 L: j' N
},
) `3 [. c; H! @/ J {
! w. U4 L1 \) A0 D' k1 D .active_low = 0,
5 G' U! r7 {$ `; }# M .gpio = DA850_USER_LED1,. Z! r: |4 w8 d3 h, D, t
.name = "user_led1",
. O D1 g/ O! C* F! S# Y; ^) I .default_trigger = "default-on",1 c; R5 v% p0 ^. Y; e$ G
},2 W% i# c) R; ~$ K' n- m" u" t
{
5 r+ X* u, s8 u) j; @+ c1 O. h. z .active_low = 0,0 o6 x } w9 j8 r. ]
.gpio = DA850_USER_LED2,3 O& b$ _! U. C) S- d
.name = "user_led2",4 q% a! q. P4 x) C$ \3 Q6 D0 t4 z
.default_trigger = "default-on",2 D% Q( _) @ o
},
& \4 C# X& Q; P0 c) y* N {
1 h+ H3 V: A3 e. I; u& H .active_low = 0,
8 B; L. r4 Z+ w' e) x% W* i .gpio = DA850_USER_LED3,& x: E% g% ?& F, z/ h
.name = "user_led3",3 g, Z! N0 z6 k
.default_trigger = "default-on",
4 o& X& l, w. P# r' l },
& L) m0 x+ h7 I6 a' K: R" l};: ~0 p5 v h+ z( x3 o* g8 Z
+ f @0 I g0 u9 {; _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, e$ g! D' u9 O1 S7 N1 b
.leds = da850_evm_tl_leds, p/ h# g: I4 k/ V( W: a0 ~! I$ b# X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; r$ u" G' C" k5 F/ V};; Q; g& }: V }9 k- l4 y
0 F& G" e7 W* p* X4 O/ O5 @
static void led_dev_release(struct device *dev)
4 N, y) k) k4 b6 r{
" \) U7 z, ^ o$ E: v/ ~};
7 l B4 L2 X0 Y1 |! L. k# Q1 K
' P% r0 [5 n; l/ j! V$ wstatic struct platform_device da850_evm_tl_leds_device = {
3 x y6 }# a9 C* o" H- Y .name = "leds-gpio",; |: }8 L' Q3 A$ q# c
.id = 1,! F+ O% [& ~+ I. u" ]* L8 d
.dev = {8 w5 m; ]% U/ Q( {. e, K) Y" w
.platform_data = &da850_evm_tl_leds_pdata,
3 a2 c8 E: |- u" U# B .release = led_dev_release,
* l2 L# v1 ^! J( u5 l4 _ }
) u5 t7 k& a Y( P5 o! J};7 Q8 @4 `# z# K! `& K: l: x
- O6 F: D' a u$ N
static int __init led_platform_init(void)9 q5 [) S0 K# E4 u/ h$ M
{
, W4 k. }8 H+ E' |7 c5 x int ret;
/ N" j0 a) ^( {7 j#if 0
0 x7 l7 a% b; D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 p- A) r( V/ R- A9 f9 } y
if (ret)
! M/ @0 H; _$ x( z1 k& K$ o( Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ y. ?( }3 D2 X# c& V
"%d\n", ret);
0 u3 D: f9 E3 ]0 a1 N' H#endif g' I5 d. ~3 R, X8 {
ret = platform_device_register(&da850_evm_tl_leds_device);
4 U |# a5 s/ N, I( F! n+ A if (ret)% c4 C1 {3 }* ~. W
pr_warning("Could not register som GPIO expander LEDS");
# X; Q, u3 [& y2 {! H# I$ R$ n) ` else8 `! t2 b( y m- L5 \3 v4 n; L ?
printk(KERN_INFO "LED register sucessful!\n");
- R! [! ?8 s: S5 L5 m" ?: H- B) L
; S- _) N7 {+ g# M return ret;
- @! e/ `4 h; c0 \/ m" n$ C}( U- b% _& b& w; L
' s0 Q" ?$ W1 U5 u& u6 V
static void __exit led_platform_exit(void)5 H1 I* E2 T4 U' A s% R
{: }6 a( b9 ~8 f, D9 X
platform_device_unregister(&da850_evm_tl_leds_device);
7 _" p' a e8 O" a7 ?
) O* h; |- F0 ~( J0 n4 g$ M3 _ printk(KERN_INFO "LED unregister!\n");
3 ~) @0 k m( O$ d% Z( j}
- y3 B% ~3 ~& S8 j& c4 ]9 z; {' B: s! M4 b5 N1 w
module_init(led_platform_init);
; v8 k6 ^: r6 y8 Bmodule_exit(led_platform_exit);
/ w" |) j# ]2 x# p( U9 _+ ^$ e* m
MODULE_DESCRIPTION("Led platform driver");
( x% E. B3 _5 h l/ n8 H* v7 i3 A8 ?MODULE_AUTHOR("Tronlong");
) Y0 o% R r7 K$ I0 S: WMODULE_LICENSE("GPL");
1 P E7 F# K8 b) @1 F2 X' ?( M. y; W/ b" `% d
|
|