|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ c( z6 z* n' `! t1 r* f4 I
#include <linux/init.h>- @/ ^ b( T. ^
#include <linux/module.h>% G' f* G0 R( ?& D) x
#include <linux/kernel.h>( v! M9 w/ ]% c; @% R- \( n8 j; B
#include <linux/types.h>
: |; `5 z. q4 k#include <linux/gpio.h>
: j4 `' s: ~ A# d#include <linux/leds.h>
. e; F8 S. \/ ]#include <linux/platform_device.h>
! i& n6 F4 E8 K6 D8 P$ T$ Q$ B1 q( b$ i9 t
#include <asm/mach-types.h>; W$ t% x, R- J6 j \4 Y
#include <asm/mach/arch.h>
& w/ U! s1 \! b0 z! Y" F4 s#include <mach/da8xx.h>' e; d3 h' N% \7 l8 i
#include <mach/mux.h>5 i2 y1 T& ]- Y* ]7 {
* y7 c( i: D8 G+ C8 I2 `2 F4 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ \2 [# v, h( D m d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" |1 A* Q* Y _6 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 j, G: M$ }: ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! f" N) C$ {' Y, L: W/ G
- |2 R% s5 x) U/* assign the tl som board LED-GPIOs*/0 ], R8 s, z+ X* l2 {4 w
static const short da850_evm_tl_user_led_pins[] = {
, Z+ }# D: {; [; D /* These pins are definition at <mach/mux.h> file */( b5 O- s% X9 W7 y7 C5 t1 e0 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 N( P2 E7 i: O! P5 k7 N1 { B5 b+ N -1- N, I3 m' g! L! S! T- n
};- T' |2 m( r: Q5 Z; F* |7 |
) M3 M' T7 z1 X I% X
static struct gpio_led da850_evm_tl_leds[] = {
3 O1 K; K* ^" T8 Z- v {
7 L8 |" [; B7 p' x! Z2 T* L .active_low = 0,
. P$ J* r9 m) p) S# T, k .gpio = DA850_USER_LED0,
5 F" _& k+ X* k .name = "user_led0",2 k' l0 K% o. ^. g* z. D8 {5 |
.default_trigger = "default-on",0 F% k P1 y$ x
},) _+ j; v$ j! {4 r
{+ w# h" G9 W7 L- `/ i8 u
.active_low = 0,% v, l- x' }; U) P0 D% X! h
.gpio = DA850_USER_LED1,
! w6 d3 [5 V1 {: k, k# u .name = "user_led1"," g! a! z6 I" D. C V& V! {. ]* t
.default_trigger = "default-on",1 \5 i1 K% J$ j9 M& h) U/ J2 f5 ?/ x
},: f {' W6 c9 p8 ~9 O# Y
{
7 _$ m0 D1 y0 f .active_low = 0,/ G$ \# P# G+ y2 b8 b
.gpio = DA850_USER_LED2,. R: w' ^$ L5 }: J: R
.name = "user_led2",, i5 l8 V+ \! c9 z G
.default_trigger = "default-on",
v* R S, q. S8 A$ ] },
$ k) T$ f6 ~3 ^% ^3 P {
5 M9 O h A& \3 n. [7 x; I6 ~ .active_low = 0,. B% v @. p6 |$ i
.gpio = DA850_USER_LED3,( b- f% ^- z2 z$ W- l" D
.name = "user_led3",
$ l' r7 P* ]1 _# x9 x2 J& K .default_trigger = "default-on",* m4 |9 l& ^) W" O% N
},1 f/ A1 t% g4 O* Y/ T
};
$ |9 a- Y) t2 B A' [% I. }% x: x1 o0 m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# r+ b- P2 ]" X5 g/ y) L .leds = da850_evm_tl_leds,
, q! q# y! t$ A# d9 f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 S n9 S) I! R3 N+ \};* Q" w" l' G! G
6 u' X' d3 I1 s. {static void led_dev_release(struct device *dev)
% t5 q8 [- h. z{. k% E! a4 C' @8 B1 U/ V
};
s2 K4 a; E5 s# G1 `0 L+ O& v& y5 b5 c* W5 V8 e# Q Z& W
static struct platform_device da850_evm_tl_leds_device = {7 C, _% q& A7 S9 M
.name = "leds-gpio",
, ^ F; _$ Y8 G2 r+ }6 N2 i# c: s( V .id = 1,# h( m% X- K: b2 o& n
.dev = {
0 a3 a* M, ~6 r7 { .platform_data = &da850_evm_tl_leds_pdata,( I0 F2 f5 J0 E; O7 J! b
.release = led_dev_release,
0 K( o$ Q: |2 i( t5 v }
7 ]% s' _* C9 ?' J7 c};- I9 G6 E( c5 G/ b" o" t* S
8 k% r: m# w. X
static int __init led_platform_init(void)! [- A T7 ` _- c7 S) k
{ r6 e/ p: @% c$ ^- m! m
int ret;
6 B9 h) q7 N2 L. K7 }#if 0; B5 k; l( K) w& N5 h# p& Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' A t, `* p- U0 U+ ]& y: u
if (ret)
7 u- P0 ^4 m; ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 ^9 A% g- x* H2 s "%d\n", ret);4 A( i1 f9 r3 N1 D2 Z
#endif
8 x6 n) B# Z4 H6 f9 H1 E ret = platform_device_register(&da850_evm_tl_leds_device);
$ O5 L3 N& @5 A; F6 k if (ret)0 d! C- E: t2 g
pr_warning("Could not register som GPIO expander LEDS");
9 i0 b ^+ @* S+ a else4 p; q6 l4 Q/ r7 e
printk(KERN_INFO "LED register sucessful!\n");4 |# ^: b5 d3 U j2 }
1 Q q" J' L1 h! e# s return ret;) |* t1 K0 I3 ^1 }: s: Z a3 Q! Y
}6 Z5 d$ b1 x9 ^- @8 b2 @# Y& w
$ e, s0 k5 h" G1 U! N
static void __exit led_platform_exit(void)
% d/ V& m: U. H. G{
: q1 V4 c8 F, T8 s platform_device_unregister(&da850_evm_tl_leds_device);, R- b+ ?) ]$ V$ @+ I @
, B F9 n: v1 Y# Z: O" m: l printk(KERN_INFO "LED unregister!\n");
4 s4 I0 V2 v9 E# @, s& H) j+ }}
4 m9 |. }2 C; l2 k/ `. I( v
& L$ N9 a; d2 o. O5 U! [6 `3 Kmodule_init(led_platform_init);5 Q2 `% l: g" o* j8 M% E- d: n& U1 Q
module_exit(led_platform_exit);
: Q# _- n2 f" E8 J* ]: s
# n- f6 ^( T' Q% Q" x+ X$ B* s7 p- ZMODULE_DESCRIPTION("Led platform driver");% { v9 h8 }4 t4 b! ?; H
MODULE_AUTHOR("Tronlong");
( ~8 j5 w. O2 h2 u m" |MODULE_LICENSE("GPL");
( L7 a9 j* e' s# V2 X7 }$ C1 u' T) G. r/ y+ }
|
|