|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) j% |/ L" ]: N6 l$ u#include <linux/init.h>- b: [3 [6 F0 n* g( @
#include <linux/module.h>4 | J- j5 e: h0 y+ r
#include <linux/kernel.h>* ^$ A3 j4 q6 ^# y: Z: C! \
#include <linux/types.h>0 ?9 T; B; F2 ?% M) Z8 m. t! c
#include <linux/gpio.h>
$ n O# E: W1 c$ K: G#include <linux/leds.h>
4 h4 Y- z% e" D1 V% t: L" t#include <linux/platform_device.h>. @: j5 Q n% m% a( F) d' C5 _
0 [ c( z7 ]2 F4 i9 i( k7 x) |#include <asm/mach-types.h>
8 J h' @7 _& b: G: J! f( Q" v#include <asm/mach/arch.h>
1 M: V. ^, C) g9 B8 j" ?, `#include <mach/da8xx.h>4 U) G" @- G) g s" h: U
#include <mach/mux.h>( z( o: j3 c' `/ {. ]& Y0 @
7 I% L/ g1 a7 q" E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 |, w. {% J+ Y4 z7 r A# {4 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; E7 l. {, s( |& @! _3 M6 b1 U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% n# n Z! `. D) `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 b0 f0 v3 ^* @& g: V$ Z
/ o# c! @" D, u* i' \/* assign the tl som board LED-GPIOs*/
! z' I) @5 {% z* Wstatic const short da850_evm_tl_user_led_pins[] = {
# h5 Y! g, U+ N. _1 V /* These pins are definition at <mach/mux.h> file */2 a1 d2 p! Y: S5 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 S7 h- m, X7 U5 o -13 n7 y8 A" s C- }5 Z
};
3 Q6 A2 c0 o* o1 K T
" I9 w5 x6 ? S5 t" k" M5 Z& p7 `static struct gpio_led da850_evm_tl_leds[] = {
) j! [* o) Q0 a) V; U5 { {
4 y" Z' p: F# {. I, c: x& Y8 a .active_low = 0,
4 r4 a5 _4 x* B+ ^# a0 x, ?5 W1 n .gpio = DA850_USER_LED0,
$ ? c0 s7 E5 _/ z .name = "user_led0",# N9 _% N5 U# H, A
.default_trigger = "default-on",
& g, @7 I: R7 }. a+ l },6 z. s* S9 Y( m5 l5 o$ ~9 l
{. U' k" q* O/ L* ~2 }
.active_low = 0,2 f) `6 V# b3 h1 {% e
.gpio = DA850_USER_LED1,/ Q2 O8 h3 q6 @$ H' ^
.name = "user_led1",7 P! q \5 R+ H5 s2 @
.default_trigger = "default-on",* k c/ q2 Z5 b9 b& L c
},! L' z% Q) k# T
{, ]' i! d* Q, b: r# K& P ?5 f
.active_low = 0,
, a. k2 N! J7 ^! W* I .gpio = DA850_USER_LED2,
( p- J! _& W4 p% L# I) n .name = "user_led2",
" Q; z; L% L' f; W" c4 B .default_trigger = "default-on",
* }/ B" n& d" P$ ^$ M _ },; P! v) |- V9 I& T) V: R; v
{% F) Z+ ~$ o3 V# u
.active_low = 0,
! k3 S; P1 V: d4 C2 H* O .gpio = DA850_USER_LED3,7 p# |) M$ A1 s5 V2 r
.name = "user_led3",
* a' |/ z2 q: g5 y0 f! \/ n0 f .default_trigger = "default-on",& K% D2 m1 p& U% _
},9 J1 z* r$ [1 j" Y& }& ^ {
};
2 E) c/ F. u3 A
) K/ |! K$ x. ^3 ]& d. U. g2 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ W8 n1 D v0 \8 O3 W
.leds = da850_evm_tl_leds,
! |4 O; `8 S4 B* O; a0 ]& p2 h0 E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, H( Q8 I* s6 E8 X4 z7 e$ C
};
4 S9 F' D, g& v* A! \0 F6 t9 o- V6 X* R7 D1 z" D5 x
static void led_dev_release(struct device *dev)
F) L- S- J( _ Y% X{
, ?; {' D0 [5 {% Q) x( Q- ~};
+ Z' i# H# A4 K7 s4 @+ i3 z
3 P, I% Y) N$ l& F8 C3 b& nstatic struct platform_device da850_evm_tl_leds_device = {
5 Y# J' ~* D! W5 V, G .name = "leds-gpio",
0 H7 {4 B& P/ ^4 j( ]! a8 g .id = 1,
9 i2 c; B% I5 ~- v, k6 X& X4 A .dev = {" y; |5 G5 ~3 m% D& y
.platform_data = &da850_evm_tl_leds_pdata,
7 M* [ L( z$ b3 V. h1 ^9 i B" c .release = led_dev_release,
+ ]! \, R1 V3 a; H* a: y }' F3 A3 {+ j/ U2 w1 b, B* `: q$ b
};
1 t& A8 \+ o8 h$ \
$ a) y* h P9 }: i* sstatic int __init led_platform_init(void)% A# I; E' J: y1 T6 y
{
8 B* Z6 z1 i8 W% ] int ret;; K1 A' j8 B, i/ J
#if 0
7 S: k* j) y; o* x) _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 ]/ } J. b9 e" c1 D
if (ret); f# t3 P. u) ^- P/ c: d; O7 N' A+ Y1 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") G$ \: [' r5 e. s5 n
"%d\n", ret);
- W4 `+ o$ {* T% @#endif
+ d# H, G3 u; |6 U& o: z# i, h7 R ret = platform_device_register(&da850_evm_tl_leds_device);
# T" }( f: R2 v% f5 V' v4 k$ v if (ret)! B% r# v) |& b. O
pr_warning("Could not register som GPIO expander LEDS");
. o9 V3 u& n+ E1 z! {0 [: N else
: i. G8 v% g+ b1 w0 u- n printk(KERN_INFO "LED register sucessful!\n");0 @7 s: |1 k" l, Q7 M; N
8 }+ ~- _0 _4 M: M- r return ret;
; K$ T! [/ Q! B0 D2 ]' C7 b0 g% r}
* o; O; J2 w. j4 M% N2 t1 T; _2 M" t0 U; P+ w
static void __exit led_platform_exit(void)
: d" X& s3 V: Z& z4 Q{
2 q& j# r% Z% y* j& u& W; q. { platform_device_unregister(&da850_evm_tl_leds_device);
c3 h4 ?( h1 j: Q4 A1 K9 ?+ n+ o6 y
printk(KERN_INFO "LED unregister!\n");0 K+ G. ^* y0 R, {1 h$ D+ B) \% d
}
3 r% J8 U8 }6 K/ c4 W6 ~5 H7 P5 O3 \6 O& K3 E& Y% n7 M
module_init(led_platform_init);
8 \% E& a9 i0 e. Z9 b6 t" u! gmodule_exit(led_platform_exit);
& b6 U! s# L1 H! ?5 @# K; j. p. G
MODULE_DESCRIPTION("Led platform driver");
0 z: G* C( F+ S. H/ H0 A/ c" {MODULE_AUTHOR("Tronlong");
: d- R: u L- L' U& \0 ?& FMODULE_LICENSE("GPL");
! a, k6 Z4 c; v$ `4 S& o
* U0 L/ B# W* `. I% x. Z' a. N |
|