|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) e* R5 z1 d+ u2 w+ G! K
#include <linux/init.h>
: A [+ c# T/ }0 `% ]% R! A2 }2 k#include <linux/module.h>- V8 Z5 `5 @/ g9 R4 i
#include <linux/kernel.h>
, L* j3 P$ ]: P* I- D$ x6 a u#include <linux/types.h>
" {5 ]8 i! e0 C#include <linux/gpio.h>
8 @5 D' y0 w$ L% z7 Q4 M2 J, ^# ~4 C#include <linux/leds.h> L: B8 }" V% E7 H/ c; b, A g% T
#include <linux/platform_device.h>
9 r1 L- i4 ~1 j, U
5 q; R. ], e( Z% h& J0 s9 Q#include <asm/mach-types.h>9 }2 w; S& I( L( O0 e" { Y
#include <asm/mach/arch.h> b) v0 \! ?, \9 H# ^; u: \7 m
#include <mach/da8xx.h>
; a4 w: m3 t, V9 R6 H7 o6 y @2 Y#include <mach/mux.h>3 C4 T- ` @4 u. Z
: s( \+ f3 g2 I+ H5 n% Q" c1 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 G8 e; g+ w' Z7 O+ T8 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 P9 c& ^+ l0 n9 w4 b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& W+ k% ?' Q$ M' W2 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% d _4 v7 z" G4 t c
1 k, Y$ i3 C' B% a `6 F/* assign the tl som board LED-GPIOs*/
- U# F1 k5 ?7 u8 j- ]/ {6 Q8 {static const short da850_evm_tl_user_led_pins[] = {
" l8 |; K1 u' W" ~+ s+ ]9 k6 R7 Q /* These pins are definition at <mach/mux.h> file */
& h+ F2 r5 {% g8 E2 q7 D4 H" }9 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) }: N/ t F) }! v1 B; G% b' a -1. r+ ~0 ~. g$ |; T4 f4 n9 N
};1 C( I, S3 W9 X! A
0 ^& W$ ] W1 Wstatic struct gpio_led da850_evm_tl_leds[] = {1 k8 C( p, z: H! w1 v; b, h4 z
{9 _$ [& F1 }1 X
.active_low = 0,
: u9 N, u4 ?. A .gpio = DA850_USER_LED0,
) |. Z: d! T8 \; u* V .name = "user_led0",
. S. s+ A" s6 q' e( ]5 S3 q .default_trigger = "default-on",
. Z' z. z0 O! R; O& q4 x },
/ [# } {$ s, p: t5 N5 u {3 U1 ^$ W9 h; d$ y
.active_low = 0,; S2 P3 t1 \1 ~+ V! n0 t+ e1 l
.gpio = DA850_USER_LED1,, v/ q& Z9 _, W# m$ Q* c
.name = "user_led1",' I [; ~4 f8 j" Q8 E' n5 i( R
.default_trigger = "default-on",
) E" |7 U6 t' }' ] },
6 h/ z1 O) W, q' ^' J {
& ~$ W* n2 ?, t6 E* ] .active_low = 0,
1 {* d# i- x- t$ b! ^2 g# P) f .gpio = DA850_USER_LED2,
" C1 x, D; f" Y8 L+ B .name = "user_led2",
% ]& N4 Y% d/ D) ~ .default_trigger = "default-on",
. z% R/ t1 ?) p4 i5 X6 G, ]9 Z& ? },
& @) T) r. H# K# C" M {
1 L0 u8 {# \" B: M( e .active_low = 0,
: K4 \# \4 c- S0 I) ~ .gpio = DA850_USER_LED3,8 K7 r0 \( K; B1 |
.name = "user_led3",
* v, ~, @0 K$ Z .default_trigger = "default-on",/ X4 d8 E; @) g5 d' S- E! C+ F
},
/ }7 p. H7 ` @3 b; S};0 U3 j, j& `/ q1 G; J' m- e5 B
) ?; V* `6 o! ], X. a, Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 Z& ?, `) s% E5 l
.leds = da850_evm_tl_leds,( B) h* y, Y4 G' ~. {2 T+ j4 i: r( ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 Z: O) ], ^- i
};0 N% V0 p/ c8 p0 F& Y
! b9 v; X5 d# s9 ?) i/ y/ Xstatic void led_dev_release(struct device *dev)
$ P. [7 Z* b, `{/ w5 X2 O2 ?7 |8 E
};; u* l, `" C: J: ^+ N
0 r( |- o( _0 j, w9 m7 J) Cstatic struct platform_device da850_evm_tl_leds_device = {
, X# j$ I# l4 w) n, C% n .name = "leds-gpio",
4 N& h7 t2 U; z .id = 1,& Q$ h7 C( m4 j- @
.dev = {
1 U( C8 I4 r; } .platform_data = &da850_evm_tl_leds_pdata,
% J! J5 b0 l: u4 J .release = led_dev_release,& K' b) J3 y& U M' w& i1 F
}# U! j0 B' u& x- S+ A$ x+ Z- i5 C6 M
};
5 D3 @) D0 H4 K+ a
0 C* o* C `6 p+ X$ h, dstatic int __init led_platform_init(void)0 `/ ^" R% N' h
{) e3 j$ y8 t$ n6 ?
int ret;
8 S6 \7 K! i9 k# L% I. Z#if 0/ ?; a- C* X1 V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! c' R' m: ^+ s* F J I' c if (ret)
! e0 _/ c% o' g, {' W6 v7 G9 |1 M, W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: j9 E# o1 g$ W3 S "%d\n", ret);: u O$ c# L! l `, }' E8 C
#endif
3 A8 X# f$ H5 v4 B ret = platform_device_register(&da850_evm_tl_leds_device);" L& w( @: n$ D0 |7 W% I
if (ret)* n" i% B5 a a* H' |8 J
pr_warning("Could not register som GPIO expander LEDS");0 I, @; C g* G
else; U% x S& @8 {# ~3 ^" R
printk(KERN_INFO "LED register sucessful!\n");1 W7 t5 Z0 ~" j5 M3 h, M
( z! Z+ ?% u3 z! o, g7 A& |
return ret;1 O7 x/ I+ {9 J5 I0 _7 o
}: |8 P, X' K1 ~; O4 d8 t
7 _ y9 h. ]7 `/ }# G# t
static void __exit led_platform_exit(void)0 ]" U0 [1 G1 U; J- C& C: Y/ e
{
3 G( y% f. R' T* o# f platform_device_unregister(&da850_evm_tl_leds_device);
. z+ R; C4 ]8 e' k& D
h8 U6 v8 I8 _+ r! E printk(KERN_INFO "LED unregister!\n");9 ]' [3 |7 Z# H
}
6 \7 `% X+ k5 w* ?
/ k" s1 l0 x4 X0 g' g) I1 `+ Rmodule_init(led_platform_init);
8 q! g- O& ]2 F2 |module_exit(led_platform_exit);* F1 v8 I% \7 _2 u1 \/ P
2 }) a3 M. u- H5 j- Y( r( D5 K( g2 c- |
MODULE_DESCRIPTION("Led platform driver");
4 R3 z: p3 B8 h! D' ]6 vMODULE_AUTHOR("Tronlong");* [4 q0 Q: v3 N& X
MODULE_LICENSE("GPL");5 w0 M+ _3 j3 i/ T$ o% u+ J* f6 A# L) F
; ~- v0 F5 T* r" u |
|