|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 z8 F0 q! n3 ?1 k1 ^
#include <linux/init.h>
5 J& o$ }# q/ v% _, `1 L1 Q0 F2 s#include <linux/module.h>" z& i: U* h+ x
#include <linux/kernel.h>
( J5 b r$ |! I#include <linux/types.h>
0 `* A9 H9 p1 N8 ]* h3 X#include <linux/gpio.h>
$ P. M4 e0 y* f#include <linux/leds.h>/ W( u( Q1 x( l2 H" {1 {( D0 Y
#include <linux/platform_device.h>
* U3 D9 M9 T$ Z0 ~" X2 v6 r& y) ?* G2 b7 {& v9 H
#include <asm/mach-types.h>% ~( u& C; z; B% H5 _5 v- B
#include <asm/mach/arch.h>
( F3 d5 l2 U) ~, w1 y#include <mach/da8xx.h>! m l# a) k# I& \; s
#include <mach/mux.h>2 e& i3 g( P0 e* Y8 d, I+ l9 z
b- ^: T7 N7 i8 p7 c/ {- o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 n0 I7 d; x1 {* o9 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' {: L/ T4 J, s' U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( E* @' x# A8 ^. L+ p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' f- ^4 n6 \4 O5 b, G. V6 R5 }
& c. B, r$ f; S) m! X0 U/* assign the tl som board LED-GPIOs*/
* M. I) J- U7 O5 I9 i' x$ vstatic const short da850_evm_tl_user_led_pins[] = {
2 q T& k$ z2 v+ D /* These pins are definition at <mach/mux.h> file */
! w% \0 ~. f- v5 }( ~8 D) V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ p5 j! b2 x+ \* L% D6 w -1$ u$ ?# m% p3 e1 U$ H! I H
};/ |" [6 C5 f4 _3 d
/ G( m2 F" ^5 P9 X$ H! w
static struct gpio_led da850_evm_tl_leds[] = {
/ c# o" e; I: l6 F {
3 K- Q/ U. l0 L* ], N* o3 M% ]9 l .active_low = 0,
) f: ]. |9 a4 A; ]% L .gpio = DA850_USER_LED0,
' d+ D1 l/ g8 C% Y* w9 t6 C" v .name = "user_led0",
9 |! ?7 p% t' ~2 O, n .default_trigger = "default-on",
6 q, ?: \. S9 k$ K },
/ G6 X& ~5 y) E5 I( w& \ {
+ J9 C# s& W+ [! W& F .active_low = 0,, c3 D Z- {! \- ?& j8 o# X& r/ r1 `
.gpio = DA850_USER_LED1,+ r! Y9 b6 G1 x5 B
.name = "user_led1",
' B+ }( ]: o/ ` .default_trigger = "default-on",9 @4 X+ x" A; Z3 h2 n7 ]
},
9 u- e) T/ C. @9 U {
2 x, E0 q9 W E r .active_low = 0,4 |( P5 V2 v4 Q
.gpio = DA850_USER_LED2,( Q# Y9 [. u, p
.name = "user_led2",( e( n q7 g% ]0 ~9 b" L
.default_trigger = "default-on",8 z1 m4 F% [; i
},. E. B3 W( r; J- y" M/ r
{
* K$ x& n1 N& D/ k- F& h( [ .active_low = 0,
u( t: u8 k# i, ? .gpio = DA850_USER_LED3,$ f. G" \( L: @2 |5 x, x: t
.name = "user_led3",
, e6 k' K/ B3 N" o2 `7 y .default_trigger = "default-on",% B7 E! u1 P: ?! U5 d( s- w
},; S- }& H& [' d% P1 x# l
};- {4 n7 H2 s# |( ^% ], r
0 e( E8 |5 r4 _+ F7 ~% Z% fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* O8 t# M$ E2 _4 ^8 P: I .leds = da850_evm_tl_leds,
! A) X, \2 ?% S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 }2 W- q( N* ?
};% v* Z2 F \7 X/ x
: N% N! K0 p7 `static void led_dev_release(struct device *dev). {, C6 p# R5 Y/ t. p
{7 ]+ q" f" R0 V1 b+ p2 M. ?
};, v+ h- J$ y8 f
! ~+ p$ T& e& Q: f- ~+ Tstatic struct platform_device da850_evm_tl_leds_device = {
K; m+ Z# V% J4 w5 R .name = "leds-gpio",* @+ d0 I3 Q: l3 @
.id = 1,
* L; }1 T# W9 S .dev = {
) g5 e, ^! E$ ?5 m1 M, @ .platform_data = &da850_evm_tl_leds_pdata,
0 M) ^2 Q( y1 Q+ C1 q/ n .release = led_dev_release,
. N, V9 K! y7 f }
$ U; M4 O: R$ L};
6 ^) I& o; [* U9 o9 G0 G( g" }; b2 P0 ~( ]6 E- ~7 a7 V, t
static int __init led_platform_init(void)1 `7 |. p; W1 b; }/ [; w9 L
{
6 `; @$ _4 R9 l2 \: U7 x int ret;
' ]# P9 z1 I( L! N8 Z. ?( B' M6 r#if 08 K& _% r0 w+ u* F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. Q! E; q9 q, Z$ u4 v4 B a$ D
if (ret)% L: e! z9 {/ r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& j: |6 m+ \, B6 b
"%d\n", ret);) v$ V% Y; h5 Y* e2 F- u
#endif
2 O8 P6 Z; E' o4 x" z ret = platform_device_register(&da850_evm_tl_leds_device);
8 c* [3 W7 m4 @ if (ret)( D. i9 U8 X0 B* E2 F; v
pr_warning("Could not register som GPIO expander LEDS");
5 U8 g) Q1 C+ u else, K1 K( \, M% ]7 ]) \
printk(KERN_INFO "LED register sucessful!\n");: B. a$ h" h6 O& A3 r
) M k( n9 `! q+ h7 ?, X return ret;* p4 S! {) `+ e' e1 v
}. t! j: C4 C& l: z3 @
6 }6 X3 H4 R9 t+ c2 U9 _& w( Z/ Vstatic void __exit led_platform_exit(void)
! ~$ _ a2 \. M% i$ S{, U- J& N' D7 j1 @- d$ l
platform_device_unregister(&da850_evm_tl_leds_device);1 X7 X0 G, F$ e; M
8 r8 _1 y/ }5 }2 b$ B: b ~5 X printk(KERN_INFO "LED unregister!\n");
) H$ \3 [" S5 r5 C7 ?. S}
. Y- j1 `& r# G& ]8 `
' M6 S8 c3 [, X" b+ |1 Bmodule_init(led_platform_init);
" ]( z# q9 I; U" q: x7 R# Z( W; ~module_exit(led_platform_exit);6 b+ F: y9 n0 Q6 \
* G. y/ V0 B1 `
MODULE_DESCRIPTION("Led platform driver");2 E, A4 r6 E: u
MODULE_AUTHOR("Tronlong");; D" i6 m+ B1 F5 P9 g
MODULE_LICENSE("GPL");
5 ~; ?8 g1 Q8 j9 L* J0 ]" B# _& J* U+ U6 j1 @- u
|
|