|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ Y# I; M- f6 G5 H) h2 z#include <linux/init.h>
( `" X2 Y: P* N) R o#include <linux/module.h>
% Y8 n0 B# f- ]; a+ P#include <linux/kernel.h>- A! ~* e- I% `1 J% {
#include <linux/types.h>! [1 B: s+ P/ n0 K; H/ t( E- [
#include <linux/gpio.h>
5 a- G; `2 R0 p& \! p8 _( ?" I#include <linux/leds.h>
% a; |9 r, p m! G- V: N#include <linux/platform_device.h>
* q0 q, p. e, u# a! b9 ?' F p, C0 ?
#include <asm/mach-types.h>
$ v, C7 D5 B- p& `#include <asm/mach/arch.h>* E* O( s2 @7 s. O( F4 e6 J
#include <mach/da8xx.h>9 u/ u) v& {) ~; m3 n
#include <mach/mux.h>( n1 m: o* V1 A; q! L' Z2 s
2 E0 @& ~1 O: R' V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" |, p8 w1 j2 r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; N6 v. E0 l( H y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), {2 S7 N5 P3 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 @" R% A2 C5 ?) x4 U
; V' h$ x: e& q; `5 r0 ^ ?- D/* assign the tl som board LED-GPIOs*/
, l' g" G. j9 l$ ^0 O% `static const short da850_evm_tl_user_led_pins[] = {5 ?, ^8 c3 f0 o$ l9 |, T. i
/* These pins are definition at <mach/mux.h> file */
( J+ q$ V9 q( S+ u3 f. J/ A0 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& v- L8 T( r, F* A3 {' E3 \* a -1+ V, z' k4 X3 R+ n* W) }4 Y
};
' Q( V# B, n, i% u+ O
7 }4 I! |& `& H2 q% c6 qstatic struct gpio_led da850_evm_tl_leds[] = {* I" X: C* g* d
{4 m" ?, n# l* Z0 `# j& m
.active_low = 0, O) P3 \# H! z* Z: E2 Z* h- n# w
.gpio = DA850_USER_LED0,
2 m. L+ P) E0 Y* s' t .name = "user_led0",
' n; M' ?1 ]7 k# K ~( B5 J .default_trigger = "default-on",
) a& Q, m5 m( s' L: H7 I },- b8 k8 v1 t, M% |& C. u' y( f. {
{5 `9 S; q) ?5 {9 O+ B2 a3 n/ H$ c O. n
.active_low = 0,* W y( l, e4 l! K3 _ c( y' U
.gpio = DA850_USER_LED1,1 s6 I. d$ k; f
.name = "user_led1",4 s6 d3 K( ^2 y0 p* C
.default_trigger = "default-on",
5 z% a0 {3 y5 G7 Q& d& _4 ` },
+ F* u. a( ~" `- u( u/ } {
2 ]1 q/ n: `: M .active_low = 0,* i- \0 K8 x0 y i
.gpio = DA850_USER_LED2,1 M2 t1 O! i4 w$ D1 O
.name = "user_led2",
4 H! T4 Z1 O, K% E" g .default_trigger = "default-on"," s2 H4 A! Q) y: c0 }; x! k
},4 I5 ?2 g% H& ?5 z, {
{
0 k) j. K* s4 X" i+ V# h2 \) B .active_low = 0,
& Y! k& x7 I2 g" L$ e8 j8 z .gpio = DA850_USER_LED3,) m+ y- y& j8 P3 j
.name = "user_led3",! a% t3 q2 d3 G
.default_trigger = "default-on",
& @1 F, \! c1 T0 a2 i; w3 }! ^ },+ g! t% v+ C6 o2 ?$ I9 I
};, L: V) E$ b0 E9 }5 c
3 W, ` J" S2 v5 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 X5 M0 _3 C1 |" X
.leds = da850_evm_tl_leds,( y0 W3 C, `6 n+ H3 J5 Y2 \: i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ p6 H( n8 b, W' z. V) z! Q};
" p* ?% e8 A0 ?8 z
: l6 f _# ]7 S' k0 Z; Gstatic void led_dev_release(struct device *dev)
( y% b2 Y* \) _4 H: P{
: y. u9 ?' d6 g1 N};8 Q: m' g6 F0 ?; N
7 p5 v1 ^' g- y, B- s3 Ustatic struct platform_device da850_evm_tl_leds_device = {
7 Q% M( I* W( A, c! O$ o) r g3 d7 j .name = "leds-gpio",
2 O3 X# k' S- Z8 B" g .id = 1,$ x) t5 A" s6 T- Q _
.dev = {
, ~2 J3 Z1 X; z- _. I% m! b .platform_data = &da850_evm_tl_leds_pdata,
# y$ b. f/ k/ y9 G2 I1 [6 K .release = led_dev_release,
0 p* J# Z/ c' Z* L }
' \5 b4 D- r$ z; M$ N1 S& S- {};1 ^% e; f) m' @5 [4 l W
( ?5 \5 I* ^# ?" j
static int __init led_platform_init(void)
- {! }$ O9 u+ D* H; X{
% t* O: `. [: P! @0 S int ret;" u, \& q! J$ w2 m z+ g
#if 0
# I1 l& R2 k6 Z/ t) d5 v: i' K$ q# N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 m& u+ V9 k" P& V# H if (ret)
( i) u* _' Z1 l: O% Z& M( u& q pr_warning("da850_evm_tl_leds_init : User LED mux failed :", c5 `; a, u4 C2 H/ n ]
"%d\n", ret);
& e/ s0 V$ w: H! L3 l#endif6 K- R7 }# N+ u) q
ret = platform_device_register(&da850_evm_tl_leds_device);
) r: `4 i1 D7 i if (ret)
# S/ O$ _4 }& u+ I, Y pr_warning("Could not register som GPIO expander LEDS");) S% U4 G1 Y% s! H
else: G+ i. Z$ A/ c0 {) i$ _
printk(KERN_INFO "LED register sucessful!\n");
& Q4 U' G% ~- S# @% W k6 m% u! @4 ^1 B/ z3 w0 p
return ret;% ?& x& f6 c- {" k! z3 Y5 V' ~
}6 W: D& p- r2 e9 `, h
6 E. a a- o# ?% F! X0 _static void __exit led_platform_exit(void): Y* ~2 u w a4 M% g( P* F* n
{
. n9 B) W$ o3 S# ^ platform_device_unregister(&da850_evm_tl_leds_device);% L! D G( z" ^3 I' q8 F
# [! ?3 H" }8 ]' L8 M0 X
printk(KERN_INFO "LED unregister!\n");( f/ G5 Q+ T: A. c S/ q$ }% j n
}
+ x( D! G$ O9 {. e5 A1 x0 e. c; u% i$ V( ^0 h
module_init(led_platform_init);) n R3 e8 M5 Y( Q% J
module_exit(led_platform_exit);
; Y, f' ?- h& S
( z9 x. m3 h' p# ~MODULE_DESCRIPTION("Led platform driver");
5 G1 q# r3 {( p& BMODULE_AUTHOR("Tronlong");! N. N3 j2 ^4 c0 i7 ?9 R0 o3 ~6 P
MODULE_LICENSE("GPL");
% J O& u0 }- K+ y+ y: A6 M5 B3 T8 f: T, M: Q
|
|