|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& G; j2 `* i5 W/ h* p* m#include <linux/init.h>) w7 i" X1 ^' Q/ F# \
#include <linux/module.h>
% A# [' D, m8 J6 M- l8 y#include <linux/kernel.h>
, I+ j, h3 f6 A9 @ @#include <linux/types.h> N1 ^% N, U( N. B0 v# n
#include <linux/gpio.h>
4 w5 v5 ^! u: y/ a$ g9 O/ \#include <linux/leds.h>
8 p9 N( m. @( y4 `' W#include <linux/platform_device.h> S+ X+ C; I0 G$ k7 X; e4 {! l
9 @" e1 c: w3 n5 p4 F
#include <asm/mach-types.h>
3 r$ G D( U) o& O; \$ {#include <asm/mach/arch.h>
4 j6 B& _5 x' l8 n/ F, t9 d8 m#include <mach/da8xx.h>
7 p$ \/ V9 v3 G#include <mach/mux.h>
( W2 y) j8 w- r
' X' Q* G n4 e x* t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). I) A& h7 i" U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* ?0 p# k8 J+ K4 _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ s i' G6 _# J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% Z( f" V& H! a5 D
8 ^0 f" p8 Q0 z/ f
/* assign the tl som board LED-GPIOs*/
% t7 N5 O! A; a6 `& O% vstatic const short da850_evm_tl_user_led_pins[] = {
: L" S, b2 r1 t. ?3 F /* These pins are definition at <mach/mux.h> file */
$ A& j8 g- k4 R9 x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: Z2 }5 H3 _. v4 D- Z v$ B8 w
-1, }; S/ f j2 U4 U0 m* G- ^
};
5 I, o* H u7 ]2 r. j' G% M1 _
$ F7 R' M+ j" _0 ?! u0 Gstatic struct gpio_led da850_evm_tl_leds[] = {8 U8 K( q* m& _$ c
{
- X& I, r4 ?# ^- q- a4 s' A .active_low = 0,! o! c; U2 W/ t$ w( h
.gpio = DA850_USER_LED0,
; L+ k/ \4 W- A) G3 ^6 ^ .name = "user_led0",
( R: k" u( i* U0 a6 n% T9 x .default_trigger = "default-on",+ I: z7 | u+ k4 P; ~+ Y
},( b1 s$ N, W7 E
{
1 g8 n6 ^ [* T7 Y) h- w .active_low = 0,9 @" }& p7 X3 c' B& P& y6 V0 c
.gpio = DA850_USER_LED1,
: U$ D' l0 M& G& Y* N' ?5 [ .name = "user_led1"," @7 D6 b5 h1 X& f% A1 p
.default_trigger = "default-on",0 S9 E+ ?: U- J- g8 f
},1 a, h4 e7 k3 q- i7 [6 T
{$ J' d4 v( S* |+ t; v) ]
.active_low = 0,
" O! q6 y. S0 \5 Y .gpio = DA850_USER_LED2,
' C( w' t' ~4 F" V6 R$ S9 I .name = "user_led2",
+ N4 { a6 {. c7 S$ M8 U6 q0 f8 `- T .default_trigger = "default-on",2 |) ~. ]) |& k7 i, A! A
},
# W. q2 k- w$ b6 M$ A; I+ B: L {
. y8 P1 N7 J/ P+ Z/ X .active_low = 0,3 \8 m$ _6 v& |1 w- }7 ?; g
.gpio = DA850_USER_LED3,
u! c1 m: M6 Q! n: M3 Y) V8 |/ t+ | .name = "user_led3",) A. ^; \ ^: ^9 X \4 T
.default_trigger = "default-on",
7 t7 W& J4 a3 x' E) d! [ },: I9 v3 N1 N" a, Y; Z2 ?
};2 o) }0 b7 J1 M
M! b8 B" U) h2 ?1 u" G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 ?4 }7 n: |4 K% r3 t: u
.leds = da850_evm_tl_leds,
" h7 S7 W7 O- v {; e" R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 ^$ i* |3 [$ [+ H; C6 K/ w
};
% g% _8 _- B/ k: J1 _! t+ N! I1 A( _- e3 H9 e: ~. i1 S0 z
static void led_dev_release(struct device *dev), d; x$ K4 k5 V- B
{
. C6 W/ M% p2 u: R& M};
% C6 o$ N3 s) @5 r2 K# P4 o! l8 ~. |% v4 K6 Q: J$ ~( c
static struct platform_device da850_evm_tl_leds_device = {
4 i$ Z0 d" @8 S0 k! T .name = "leds-gpio",
5 D6 E7 i. N3 j6 [2 ?. l1 h .id = 1,+ |0 y6 t# [4 E, r) @ N
.dev = {
. @* E2 N- d6 s% b* h" k .platform_data = &da850_evm_tl_leds_pdata,
/ G, ? e" l" c .release = led_dev_release,
( m. N6 v/ r# E; \ }8 ~" C* N% W* {, {" G9 y3 ?
};
5 h% j, y ~; I$ x4 Z% I# A5 F6 Z6 g
static int __init led_platform_init(void)
" C7 ~- |- ?+ H$ Y{
7 ]) I O1 X9 D8 U& ~! x int ret;
* U" }% V' s% p, b; X/ A# ]#if 0
4 S2 M0 Z8 S( x# _9 c9 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 w6 X8 J$ t2 J$ z! x V if (ret) y9 V; ]* @$ \: {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 D- n B- d& E9 R$ z# ~( O
"%d\n", ret);
5 a. J% V: E. K |, A3 C k: Z4 e9 U#endif
3 H! e' v2 J# r ret = platform_device_register(&da850_evm_tl_leds_device);
6 I" q% {( |+ A B+ ^5 C if (ret)) {. n: ^' h3 B; i
pr_warning("Could not register som GPIO expander LEDS");
1 Z( ~- g8 r+ W! `- v else
; A" d- e2 a) Z: w4 S7 I3 Z printk(KERN_INFO "LED register sucessful!\n");
1 l8 F4 H s" E5 |9 ]6 X3 R
0 y% d7 \) X% J9 v" N return ret;
; ~: \6 m$ L7 \8 I" `) E' i! ]: O}9 y" J3 ]' q( h; s S3 y
* B( M4 q3 [# M8 ?
static void __exit led_platform_exit(void)
7 }! O# y& z A' B/ a{- H' T3 v+ o6 y5 C, K
platform_device_unregister(&da850_evm_tl_leds_device);
( w; o1 a- n: l K) Z
# h; \ d, L' H9 O7 b; Y printk(KERN_INFO "LED unregister!\n");: c$ T6 O# h6 c ^" e
}
. u; b# A Z k# p4 u* o1 D5 b+ g. m$ }- p( u, m7 L
module_init(led_platform_init);; y9 D O! E$ Z2 L
module_exit(led_platform_exit);
3 M: k- W3 W/ T+ N6 r8 P5 p. b4 Q7 o- N0 ]7 X
MODULE_DESCRIPTION("Led platform driver");3 M' w. v7 C" c5 F7 d% a# O
MODULE_AUTHOR("Tronlong");2 ]/ b5 H* k9 A
MODULE_LICENSE("GPL");
# o, P$ ], [3 z! Q S, M m- S/ z$ B" s1 M
|
|