|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) G( ?+ c1 @& _& j( |#include <linux/init.h>' ?5 A8 | P1 `, F
#include <linux/module.h>2 \0 @1 S9 A. [ I7 z; z0 V" z
#include <linux/kernel.h>0 O* U1 I+ g) r7 e
#include <linux/types.h>
: [+ ~ ]. k9 i8 n6 Y' B#include <linux/gpio.h>
" k) K& v& P I: G0 p8 ]' o x#include <linux/leds.h>8 ]$ n/ K+ I% I n% Q3 M2 u/ Y
#include <linux/platform_device.h>
8 W$ v! Y' b! ?, c9 w: ]# H, v- G& p3 e. a8 l, N5 D! [
#include <asm/mach-types.h>" ^/ T; [( q# z; b3 m2 ^ Z6 \
#include <asm/mach/arch.h>0 e) H6 u Z5 j: H' G5 F1 Z
#include <mach/da8xx.h>0 U5 `' p$ m& e: f9 p
#include <mach/mux.h>
5 C0 ` W' p+ q! Q' g
5 p* ~. J7 X) |! y! d% A4 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% g2 L9 z; e+ F' {2 b. A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" J4 ^" |0 T/ E' f4 R, [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 [8 V( | P0 g; }1 ]8 I' q6 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 b; T) r# r$ E0 Q9 Z% N! q
2 H/ q: N. Z5 k" p/* assign the tl som board LED-GPIOs*/
* X- A. E) t" e! Pstatic const short da850_evm_tl_user_led_pins[] = {6 ?" m1 u: ~2 E" R7 c) K
/* These pins are definition at <mach/mux.h> file */" n1 }' h* C7 ?; J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! w2 g7 |' x& G8 \; n& t" t) Y/ h2 j
-1
, ~" q7 v+ B0 z};
) U# t1 x' W7 \4 a# l1 K* j5 h
6 l4 z) C. I8 J2 _ L6 a Astatic struct gpio_led da850_evm_tl_leds[] = {9 v' t6 I4 g. S& h: n
{
- w' a9 |8 o2 l .active_low = 0,
' B8 B; b0 x6 }, f4 Y( v .gpio = DA850_USER_LED0,
5 D+ D! O O; z5 f6 l .name = "user_led0",/ s* C, G% r8 c4 P T
.default_trigger = "default-on",
2 l. y! w2 X, A: g },! k) N" w B, @7 ~
{ a- C8 [. m2 A5 ~9 k
.active_low = 0, q! n& G m8 n9 G% `; M# q0 U
.gpio = DA850_USER_LED1,
7 ^/ g: a6 R [ .name = "user_led1",
8 {# E9 m0 m% _ .default_trigger = "default-on",
! g8 L# a6 _4 [5 [; j- I. p },
0 Z, ]1 z0 u3 u {- T k# x3 c# U+ y
.active_low = 0,% o0 Z6 C9 `' I$ r( \3 j
.gpio = DA850_USER_LED2,
; F! l: X2 ~* m .name = "user_led2",
) w1 p, d& W& D+ ` .default_trigger = "default-on", r" C/ Q, o' A" g) [( `, E3 ?
},
( q7 A+ N" G) \ {
% @3 y: |" L/ U2 y .active_low = 0,
8 D( I2 B4 u' U6 }) t6 B .gpio = DA850_USER_LED3,9 ? h. {1 Y L, i& G/ D% j
.name = "user_led3"," E3 S U: y' g7 a, K: M3 |
.default_trigger = "default-on",
) ?0 ^# [5 i* c5 N6 [! \ },$ j% b1 v/ P8 e; i+ g$ v
};6 A- J5 w" G f$ ]/ w
7 ]6 z5 Z) G. u8 t6 W# W1 P! B* f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% b8 w; b- \, W .leds = da850_evm_tl_leds,
, U4 d% e W4 i3 T2 s! H: B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& J( ]+ ?' c5 C6 q: z' L
};
* Q- G6 H3 W9 P* w# N, v$ l3 F; B2 u( O+ ^. p- v" l
static void led_dev_release(struct device *dev)
: A# P! W6 e! y0 g{
+ e: s/ ?: R' a' O" c};
W! k; V2 a6 T& C t* G J8 b; ]2 e
( a1 \( x2 [+ sstatic struct platform_device da850_evm_tl_leds_device = {
7 l$ F' h$ M/ g2 R# a- C h) p6 F .name = "leds-gpio",
7 T L' r, T6 `, f! h6 S .id = 1,
( U- e5 ]& _ z5 {2 W .dev = {( ~7 `( a1 G1 c
.platform_data = &da850_evm_tl_leds_pdata,# m0 [) N3 P" m& I* w3 w# B
.release = led_dev_release,
" A' c% k2 M3 Z1 ^+ V, d }
% w2 N e, {, r" }4 u5 o2 [}; `0 w# I( w/ T; j
' V. Q( A3 k' _7 H; E4 b
static int __init led_platform_init(void)2 l2 I' y/ J \2 w
{8 M) h; c1 c2 Q. Y7 @. h5 _
int ret;
( e0 K: f/ F/ ~9 m#if 0
# ^ a8 n2 `2 s* L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) K# i7 ~ c7 D9 ~; T9 J if (ret)+ [) j& x# n8 |2 S5 ?7 |5 @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ W* C+ p& O9 ^* D& Z ~3 s
"%d\n", ret);
: C* q( G. g: C4 \' R' m5 P" C#endif7 f5 C* j1 x: ~0 Y" m
ret = platform_device_register(&da850_evm_tl_leds_device);" I# ~: x2 Y/ u! f1 B7 P4 t
if (ret)2 s* A" a$ R( v
pr_warning("Could not register som GPIO expander LEDS");" n+ ^: x6 Y B& {1 v: O, J7 ^; F
else# o) {* h# ^4 N& Q
printk(KERN_INFO "LED register sucessful!\n");
4 m' U2 ~, Q4 o) \/ ?3 p% o; [; H9 a
7 G" {4 i' h( `( t J8 m return ret; K( M+ I+ u' ~3 ]0 i4 u
}9 e% v$ S' ]! K* E4 c
( y% X7 u4 R/ R5 q+ z
static void __exit led_platform_exit(void)
" E: m+ U; Y5 E% g{
8 e9 `5 R x* d0 E# u1 Y3 i/ ~' w platform_device_unregister(&da850_evm_tl_leds_device);
6 k o+ ?& s/ ~& {# f
: ?6 m7 p/ X% @ printk(KERN_INFO "LED unregister!\n");
9 Y2 X7 j0 B7 I& G% M+ ~}
4 W+ s; _+ D2 c$ N: w8 B5 |% }1 e& a7 {2 C
module_init(led_platform_init);9 i0 L6 r9 ?7 w1 G! q
module_exit(led_platform_exit);
" x! k0 _. h* u( t% d- P" P
6 n4 O- Q, r, r+ [0 Z$ g5 rMODULE_DESCRIPTION("Led platform driver");5 z* d. _$ J" J& i: |
MODULE_AUTHOR("Tronlong");" y! C# k9 s5 r3 W9 T
MODULE_LICENSE("GPL");
( \% B& e! E, x$ ]2 U& }' E# H$ ^
|
|