|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* j0 H. l1 f# c u6 |9 `3 E/ q( p+ Y! p#include <linux/init.h>
2 c# `( K$ d# b7 ^0 O/ [' }5 `#include <linux/module.h>/ A! P3 i2 U7 ~
#include <linux/kernel.h>
% I. l! e, q5 I#include <linux/types.h>
! t+ L4 J* P; v3 i' b. G( l( U# R5 ~, i#include <linux/gpio.h>6 U% I5 `, G, `: o2 X* @: j
#include <linux/leds.h>
" }# R( A: d& i* D; ^#include <linux/platform_device.h>
4 ]- C4 ?- h' [& X7 J( {+ K9 O! q7 S& Y# L% n1 A+ M1 C
#include <asm/mach-types.h>& h! _$ D3 E: j$ D7 V* y
#include <asm/mach/arch.h>
( s% U. C5 Z) }( I& ]#include <mach/da8xx.h>* y- y% G2 I( N9 s
#include <mach/mux.h>
9 h( |% h N1 a
2 ?7 i7 e2 M8 [6 w# h% K; }: I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) m1 p' j1 l" {1 h( n4 z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* o) L% J3 @ @' M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 f' i3 z& a" Y# `) e. B+ i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 T& h1 _0 {. L# a, @+ j
8 ^ x) \1 K; F6 G9 C5 u
/* assign the tl som board LED-GPIOs*/
) }2 O9 e$ D% @; l# ~4 C3 Z4 Wstatic const short da850_evm_tl_user_led_pins[] = { l l% i7 K! |% i" j! w
/* These pins are definition at <mach/mux.h> file */
8 x4 |5 }0 @& Q* x+ \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
V2 y( z; [" H2 E8 J+ y! t( M -1
% L* E9 M# ], n D% B$ b- z' L};
& s3 C( { U. s9 D6 [1 X5 O* [. j8 x) L1 J6 A8 V/ {* C9 O0 E
static struct gpio_led da850_evm_tl_leds[] = {( f% F! D: H. U/ d
{
" h. \4 j( D2 h$ }2 h .active_low = 0,+ F3 G) }: W8 Z' M$ a. I3 d
.gpio = DA850_USER_LED0,
* ? m- i1 p! x$ H0 o .name = "user_led0",
3 [" c' f, Z% K2 B" W7 ~ .default_trigger = "default-on",+ F2 `7 _$ `+ Q: |6 g
},' |0 C4 h$ e0 |
{
% H3 l4 h- j8 L/ t' ?4 g# i# W2 p6 w .active_low = 0,
" a6 F5 e7 _/ q* B .gpio = DA850_USER_LED1,' {, @4 ^' Z4 x, M& {, g- [
.name = "user_led1",
( y5 f+ }4 @7 Y/ O .default_trigger = "default-on",8 k3 X0 R: p: p* L
},
" p7 V4 {/ H, y: n {
' |5 q! n$ W; [ .active_low = 0,
6 e f: h2 f: T .gpio = DA850_USER_LED2,- v+ K" C8 P0 g' P
.name = "user_led2",' o9 ~/ Z4 P/ }; u3 Y
.default_trigger = "default-on",
( j, h& n `* u },* t" A u2 y4 E- S7 m
{0 q& W9 D6 [! j6 Q: U, \
.active_low = 0,
# y0 I1 t, j6 O L4 |" L' {" ` .gpio = DA850_USER_LED3,3 Q3 O ^7 @# T6 g; \
.name = "user_led3",# K- f5 H# K' f
.default_trigger = "default-on",5 B+ P& |9 s' a& P7 q
},
- n# n8 @" k, U; E$ F};
3 F9 t8 c. ?2 k1 m* {9 D$ ?1 \* y' e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 _7 A; |7 K m* p" O .leds = da850_evm_tl_leds,
! `* ~* O: z6 I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! m/ W8 E, S* T4 I! y
};
9 T- ]& P% t& ?/ W7 H' q1 e0 Q# L$ `" h _5 H p) F- b6 `5 S
static void led_dev_release(struct device *dev)
8 Z/ h5 S3 ?- q$ c) F. u- T{
. F5 H0 l; t% @+ n};
; e9 w. ^# R+ r% @& n' Y) u; z- Z. Q$ D! |* }& W4 d1 A9 r
static struct platform_device da850_evm_tl_leds_device = {
d* m7 L' r; V4 i4 E8 O .name = "leds-gpio",
* V( M7 ~+ A1 G5 _* I .id = 1,
$ D# T2 |/ T6 a$ A* j .dev = {0 C8 _/ F) S' p( c* \2 P/ {
.platform_data = &da850_evm_tl_leds_pdata,, D3 m2 R, E; I1 [. d' O
.release = led_dev_release,
+ p% [' U8 n9 J" f: d }
) @% f/ V4 C) ^( @6 ~0 i" v};
8 I' d) T" @. v/ m& j6 s8 s1 V: K9 {4 w+ w2 A
static int __init led_platform_init(void), K2 o& J' K( m5 y/ [ H
{. |% U8 N+ K" w' [
int ret;
; q+ F" |& L+ S' X' O* J% E: K#if 0) h. t. N9 j/ E1 {7 v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 y9 s" P/ W5 @' C! V3 n# X; l$ H3 S. p if (ret), N% I, E/ Z% h" s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 ^. V/ X5 C1 R) N3 {& `1 P
"%d\n", ret);! D' v4 w J# u
#endif
; V6 P d S( K5 E9 V6 e; F7 S* f9 E6 m ret = platform_device_register(&da850_evm_tl_leds_device);
% i' p. A$ `0 U, K7 u if (ret)
$ g+ g; s; @, [8 S6 O. e. K4 ? pr_warning("Could not register som GPIO expander LEDS");
7 }( N6 H8 D. N4 s else4 J3 [/ P0 L* |& C
printk(KERN_INFO "LED register sucessful!\n");
' e! |9 O2 P( Z2 v$ M
$ n1 c6 j6 }' f/ {' X x, Z" c return ret;5 O5 a+ F1 P' B) d
}
; [* W2 N |' e$ e4 Q7 i1 E3 t. O4 X) F; @1 `) t" }, z
static void __exit led_platform_exit(void)) o0 D* u! Z1 `
{
; l/ a6 S, u5 M# }' S; D7 [7 v platform_device_unregister(&da850_evm_tl_leds_device);
. W7 g: n( x! [+ G* ^
- G+ e( B, ~, @" J3 C printk(KERN_INFO "LED unregister!\n");
* F2 i2 c* [* c. l}
9 W2 q _% s1 n8 H8 Q9 u- g$ w& q. m1 I$ G7 l# |& Y
module_init(led_platform_init);
\) P, ^# y w6 F; O! Z; pmodule_exit(led_platform_exit);5 G4 C/ k$ u3 y2 n% q) \, m
V; n, Y: a% n5 w5 ~- I7 Z
MODULE_DESCRIPTION("Led platform driver");# \3 E, o9 ^/ U6 R; M w8 R
MODULE_AUTHOR("Tronlong");
9 a5 d H. F% s1 K8 [MODULE_LICENSE("GPL");
q+ l: K6 `% f: Y. [" @ h# t2 {( r$ |9 N, j7 N
|
|