|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% s/ G. [( B8 W4 \
#include <linux/init.h>. b; \2 | y) n; j! W4 G; |
#include <linux/module.h>" x: T( `) F9 Y: T9 ?. D
#include <linux/kernel.h>
& T5 M8 w0 V! f#include <linux/types.h>
. @ J& k# q$ ~) D#include <linux/gpio.h>. t( c* q5 @# L7 o+ w" }
#include <linux/leds.h>- |+ v; G( n+ o3 ?: L/ J# Y
#include <linux/platform_device.h>
8 ^, Z6 e" l- r/ L! w: X( I- p! l% H, r B, X1 t& \+ [9 D0 t
#include <asm/mach-types.h>
' {# I \$ j( a" M& H' L% @* ]#include <asm/mach/arch.h>1 }0 ]* x; ^9 J/ T
#include <mach/da8xx.h>4 g/ g' g# a' }6 X
#include <mach/mux.h>0 B( g/ f6 s1 w! N3 C
: Z* p/ @9 w- ~* V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 t; X: O/ p+ b& r6 z9 H, W4 x7 f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); S8 \7 F6 r4 P! R v/ [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) [4 ]* g+ O6 }+ A! B7 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# p6 n* _4 o2 B
: T: L4 r3 t" B$ N; }" ?/* assign the tl som board LED-GPIOs*/
/ ^: V- d6 J9 A+ v; f' gstatic const short da850_evm_tl_user_led_pins[] = {
: s6 r6 x$ x y( ?! J4 w" ^ /* These pins are definition at <mach/mux.h> file */
: u7 f$ S' ^: m% d, N& R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 R0 D. D6 F/ k" @0 a( N2 o! Z -1
5 v+ m* c: X! j8 M! C# C, _7 K};+ N8 ^% f* _% S- s, Y+ Z
; Y A$ o! O( S5 i. t
static struct gpio_led da850_evm_tl_leds[] = {8 z1 N; D' p9 q$ K+ c# T. u
{# a0 I6 i2 {3 Q
.active_low = 0,
( Q) d! f' }- Q/ A .gpio = DA850_USER_LED0,
0 L c3 |4 B6 x7 i1 V .name = "user_led0",
0 a' ^; ~. P- J, P/ q: `, ?( a .default_trigger = "default-on",
+ M0 p3 `" I# g7 r$ _. U },' k! |7 o( M( W5 o: q6 V+ A
{6 c# S( P6 n4 u& h9 ?
.active_low = 0,
y7 p3 h; m1 r2 m* ?" R .gpio = DA850_USER_LED1,
* j/ q$ t0 q3 u+ q; f+ o .name = "user_led1",
7 a* E' }7 i- B5 {7 a, T .default_trigger = "default-on"," g. B) W2 g }2 `4 M1 ?, V
},. v7 n" N3 _+ t7 r% V: ?
{
# l& f+ y2 G m4 m( i& t .active_low = 0,
' Q4 V1 C* U! Y6 T4 k) |: M# a .gpio = DA850_USER_LED2,
. y+ o% y7 Q+ E' Q .name = "user_led2",
y* d, y! f, u; b6 h: D- h/ O .default_trigger = "default-on",
2 Q: c+ e# L( C, z) O& n2 G },8 H7 B8 n+ L4 ^) `# q, \
{
. @3 D# y; j0 U$ n, y$ z& _& } .active_low = 0,- C" m" ^' w- t5 e
.gpio = DA850_USER_LED3,( x: r/ V( S% K; u. s. h" H/ \
.name = "user_led3",
/ x( G( D$ S5 a3 |" B; L, w! A, V .default_trigger = "default-on", u6 Z7 `& U$ j" y5 V. j2 H
},
& @% ^0 H8 w( m};$ W ~* ?3 H3 m8 Q2 C
3 s, j6 R$ y+ a. ]9 s8 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) z: i6 x1 y. V5 O* b' f .leds = da850_evm_tl_leds,: V2 E9 `7 L+ X5 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 M- H0 E4 F, g. ^
};
) u; T O% K5 F( @+ l7 Y
( k0 A7 F \$ ]8 s4 rstatic void led_dev_release(struct device *dev)! D: b3 Y w' y
{
. b/ L* o( J- ]8 `/ X; L3 Z};- \! P7 E* U" q6 p$ R+ p- Z) @
2 a$ J f) `* m$ B wstatic struct platform_device da850_evm_tl_leds_device = {
8 g+ B. Q' |& b* ]: N8 B6 `9 A .name = "leds-gpio",, i" |4 x, }5 v, s2 U, G
.id = 1,! p. q9 d! E Y, ^. t4 B1 h3 k
.dev = {
% u% ?- X* H8 R; K& o. r. ^6 g4 ~ .platform_data = &da850_evm_tl_leds_pdata,+ R. U- \8 v- m2 t! z) U
.release = led_dev_release,
9 ~; q% f* w* Y* k: I. i }7 e1 X4 E% B/ w+ P) O
};
6 X: t2 | }4 S/ f, [2 [( K2 X+ }. e* A. q0 F
static int __init led_platform_init(void)
% e" {9 u2 H9 ~- @{6 c+ L$ D) {1 P" O+ _. R; T
int ret;
8 `3 @6 E7 G0 v9 w& z! @1 {#if 0& y a) z E7 i8 \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, z- X0 N8 y7 h2 } if (ret)
( z. e: \4 r+ x6 r8 L1 J6 ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! B3 @" y8 T5 s1 s- S1 ~2 g
"%d\n", ret);! T) |* l0 \7 D( |) C
#endif
( W O9 Q6 ` J/ }( O/ i ret = platform_device_register(&da850_evm_tl_leds_device);! I# z% E' w- Y0 E
if (ret)& v0 a' B4 [. D
pr_warning("Could not register som GPIO expander LEDS");
! N9 C8 y/ |( k9 k else2 o2 ~2 I6 Z* B
printk(KERN_INFO "LED register sucessful!\n");
+ Y P* \: I+ z% A/ T& `2 ]% A& z9 N1 e
return ret;
' }. @: _* u, p |}
+ O( k5 c+ P1 h* D( r3 B) Y9 O4 ~8 S
# ^% b( M# i: I- s+ w0 X( jstatic void __exit led_platform_exit(void): H! x# Z }; c- Q
{# k+ S0 A+ U7 f$ A3 X1 i, X
platform_device_unregister(&da850_evm_tl_leds_device);
" D, n; t V$ N3 b3 J5 O1 m0 Q# F6 G5 o! h+ x
printk(KERN_INFO "LED unregister!\n");
7 F- J' D J4 k M# D}% V$ C* t5 K9 _" ?! z% K5 h
8 \- u. _1 k" y# Cmodule_init(led_platform_init);
$ l1 ^/ t; k- Q0 Y, d' M4 F1 H$ h, smodule_exit(led_platform_exit);
: t" C0 T% I( r) d2 U$ \4 C0 [2 n, J; K1 ]9 R3 B8 E, O
MODULE_DESCRIPTION("Led platform driver");
$ r1 T0 ~9 g, n" j& `( }; QMODULE_AUTHOR("Tronlong");
4 F7 e- y) H8 [' J4 m* FMODULE_LICENSE("GPL");& b4 z" f9 I" |5 ~1 C
+ L) v5 A. G# Z9 \! w* J0 P |
|