|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 j- {$ _ [; E( X# P% c, ?6 ?
#include <linux/init.h>4 ^6 I# i* a8 N, p1 y1 R5 o
#include <linux/module.h>
4 O3 M5 ^+ A3 J#include <linux/kernel.h>
: r0 P$ y+ f: L( Y3 c9 O& J* ?; J, S#include <linux/types.h>
7 e4 M V! t9 K( n+ S#include <linux/gpio.h>- E! @: n- Z% W: t/ f
#include <linux/leds.h>" c1 V+ f' t w. y* w
#include <linux/platform_device.h>
- o1 j1 j* f* A7 k: U3 v
4 B7 P7 x2 s) R% A8 o4 _#include <asm/mach-types.h>$ \9 ?) y D, R1 r: ?& {7 [2 Z) m
#include <asm/mach/arch.h>; T# Y6 p+ e, e7 A C
#include <mach/da8xx.h>! Z! o1 J+ w+ j6 L4 J8 Y" H: g
#include <mach/mux.h>* N+ `/ B5 \/ ^$ L% @1 ]! p
. ], z* t/ u% [8 k# u4 K* X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# }6 I- }$ E4 o# C3 H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; [. f7 O, L7 D0 }* H) ^* v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( g7 O8 [' _: B0 A. s6 r/ C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). P& ^& D$ P% k# E. @, ~
( w% r* a. R+ s
/* assign the tl som board LED-GPIOs*/
/ B; Q# i/ |1 Q" Hstatic const short da850_evm_tl_user_led_pins[] = {
& o9 ]) N5 [9 d6 `9 s' l /* These pins are definition at <mach/mux.h> file */
# Z& u: c/ R, s S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- Y- Q4 d/ G, y' C -1- z1 }% O6 f6 \: Q" Y% I
};
8 ^2 k2 w5 o" P( S" G- U0 P5 \/ m' U; Y p. q7 X$ p- w/ H( Z
static struct gpio_led da850_evm_tl_leds[] = {( I) a+ ?. i1 e
{: z# \" S6 h( g/ [1 `, F) @
.active_low = 0,
, G. D! Q! H U" y .gpio = DA850_USER_LED0,1 j1 a$ j' t3 j# I- T' p: D
.name = "user_led0",
) s z2 Z3 Q3 F .default_trigger = "default-on",/ s( P# m- \. x% I8 l* p5 `
},( ` m$ r# U" Y& v- _: q
{" }' V" F" s" B3 u1 t. Z B
.active_low = 0,. v9 {# k! {& D9 c: Y
.gpio = DA850_USER_LED1,
: x0 r2 h! H* F$ {$ V+ z .name = "user_led1",
% j6 N' l" q7 x/ W; n5 }* H! |3 ] .default_trigger = "default-on",
8 j+ p1 t3 k/ o },
/ c& H: |& a0 I' x# m2 Q! V {4 `2 L5 G" j8 `, u2 X5 F
.active_low = 0," Y0 s1 G8 \( m
.gpio = DA850_USER_LED2,
& p Y, s M+ e# O( }' S1 g* W .name = "user_led2",; D- n( s! G; `7 _
.default_trigger = "default-on",5 b9 j3 J6 d1 { {
},+ E% F G) v* X, b0 \
{
5 v L4 k, I9 _" t% ~ .active_low = 0,* n9 g* |0 F2 w, `2 {( j
.gpio = DA850_USER_LED3,. J0 p [ e! B! V% g# c7 o
.name = "user_led3",/ v! J3 F2 n6 L+ Z6 O: A
.default_trigger = "default-on",
- w3 ~( C u/ A# ?. A' l },
& t3 |! P+ ?# ~4 Q" @, s2 ]};
( J$ z2 n' I- _7 |3 |8 {* ]# ?( W9 I! z/ W6 G+ P8 k, }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& P7 ?. P& U5 W; M$ c9 @1 B2 _7 a% G
.leds = da850_evm_tl_leds,' K* l/ L* [* u( Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, |. E `; V, S0 T, P3 {: y
};
# w: G9 ^8 {7 X, d: e9 L$ w- o4 t0 A/ a& y
static void led_dev_release(struct device *dev)0 v3 n/ s0 H5 K4 G+ t3 H' W
{
1 L$ v3 R7 b; D( I- w* `};% ^0 i1 @/ A6 S5 N( l& v8 ]
% N8 J2 ^1 ^ k. z3 I C# qstatic struct platform_device da850_evm_tl_leds_device = {0 s+ Y! Y4 f4 v) J2 N8 F i7 Y2 E
.name = "leds-gpio",, Q! H0 Z9 c& R- N0 S6 ~
.id = 1,
, E7 H) Y' `; O& R .dev = {, j2 d3 E- {; G m6 P6 X
.platform_data = &da850_evm_tl_leds_pdata,
% n& n) g+ X/ N8 j) y6 d; @0 q .release = led_dev_release,
9 J( h* t! X. s) T }
8 v% b( N* l! c$ U# n0 @" ~/ J3 Q};$ o; F9 s2 C$ I2 t+ e2 @5 K
+ a9 B) v$ i( n6 }
static int __init led_platform_init(void)
8 X4 F, G1 v3 g3 N7 U) D{
3 a1 d8 s' o! A4 d; Z int ret;
: Y6 S4 K0 B2 y ~#if 02 Q0 C+ B. B4 r; E0 \! ^2 B9 _1 W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ J, X6 s4 h" X, o, l
if (ret)
2 I: T' r0 d9 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" y3 K! {! N7 |6 I8 E; P "%d\n", ret);
% k% I! `" F3 u8 j: U( v8 z6 V#endif
, O* o% K9 B1 N ret = platform_device_register(&da850_evm_tl_leds_device);# ~- f, e2 M' `, y* P- U
if (ret)
+ y( l* _1 M( W3 C pr_warning("Could not register som GPIO expander LEDS");
% g- ?: S1 `1 t else
" p7 k8 L( }' g2 Z- b printk(KERN_INFO "LED register sucessful!\n");7 E7 ?$ O& \" g) a
Q8 K" p% o# W5 ^' y$ I0 M- Q& ] return ret;) s6 {9 h+ s( l, _9 w& P. z
}
2 g/ Q: S- W5 M# X* }# z: I
4 `8 |4 Z/ V" W( _static void __exit led_platform_exit(void)9 l# H4 R% }/ M j. B
{
, f: d- \( {1 A, b platform_device_unregister(&da850_evm_tl_leds_device);" w) ?% W4 Y" W+ s% m2 E* q
1 V Z* W8 `9 Z, s W( l9 q0 `4 \ L+ @" e9 @
printk(KERN_INFO "LED unregister!\n");" {. O$ I7 q4 N2 @
}% r. U& r* f. t. `* a- t
2 Y4 N& [# r3 Y& I `
module_init(led_platform_init);- r4 i1 x1 ~- n/ {& e$ ~4 p3 Q' c
module_exit(led_platform_exit);
' i7 [$ {$ z* Q5 R8 X8 L- \9 Z9 E
9 @1 K) i. k; [. P1 m% V; [MODULE_DESCRIPTION("Led platform driver");# u4 U. l! W) A, }$ P
MODULE_AUTHOR("Tronlong");4 D3 v' ]2 S2 S. q, i& p
MODULE_LICENSE("GPL");
1 W2 N7 D) k# f4 [5 |5 T0 |( U' |2 @) W+ p# y3 ?9 F- W9 Z/ Y
|
|