|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 W# m4 N; `+ g' }#include <linux/init.h>5 r3 t2 o; W8 r! y+ o+ F
#include <linux/module.h>* X' T0 Y& R+ y2 M4 ]) C
#include <linux/kernel.h>% Q2 S* k6 {7 ^* y. e
#include <linux/types.h>8 I e: G1 O, a! I! j4 q; z/ i
#include <linux/gpio.h>) o W& a3 s; t
#include <linux/leds.h>3 m8 |- s# Q5 t) k2 \! \5 K+ M
#include <linux/platform_device.h>/ Z4 r- t! e6 g% }, j
% j l, Z3 N0 U; D#include <asm/mach-types.h>+ P* w; g6 S0 y
#include <asm/mach/arch.h>
' ^6 }7 k/ [# J- W# L#include <mach/da8xx.h> d! i: q3 q* `& P6 Z C6 _
#include <mach/mux.h>
' y6 S+ u( [% c" ?+ x- `
: h: k5 e7 q6 Q. f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 g& n2 c# g0 A4 J- G( s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& A4 |/ C5 z2 k7 y# ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& H6 }' N# \( ^7 ` o0 E. \% D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 r* \+ ^8 F0 I" Y+ U
( w C3 t. ^7 h i. y
/* assign the tl som board LED-GPIOs*/
4 s( H" Y; d K4 p o3 D, C' L1 sstatic const short da850_evm_tl_user_led_pins[] = {
7 m: H: R. ~7 V- f4 K# q# i) L /* These pins are definition at <mach/mux.h> file */
3 F) K! N7 u% C7 ^% K" d+ d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 g# X H# o8 f4 x' @
-19 {* n2 y6 G) P" O3 J3 C' }# a
};
4 {$ Y Z; N! K# c, r1 a/ z- S# @1 O' p# |$ \
static struct gpio_led da850_evm_tl_leds[] = {
2 }* h& ^+ Z# r$ X) z/ O& N {
! n/ G/ F; i6 k* N8 ? .active_low = 0,6 I8 l1 Y( i) j
.gpio = DA850_USER_LED0,
8 _) W0 e: a8 @% r! ^$ v- d .name = "user_led0",
6 a. D% @( @9 B9 p: } .default_trigger = "default-on",! b' h) ]3 N ?- {9 i" Y
},
; _8 F) m& |6 g" s: N {
* g! Q8 c) Y* x' j! X% Y .active_low = 0,
6 t: Z# X/ w6 ~+ A .gpio = DA850_USER_LED1,( k Z3 f' _& S' f
.name = "user_led1",! c" L& F- w( {" R2 n2 n5 c) n4 h
.default_trigger = "default-on",8 O# @) s5 z$ ?! C
},. A, T v7 T: Z- X8 [
{1 N+ |0 f; a& A/ x7 |
.active_low = 0,
1 n( T ?" x) ~" i$ L( l( y .gpio = DA850_USER_LED2,- a) J3 M1 i' q& P$ I; Z: f
.name = "user_led2",; C6 o* q4 R4 v A8 K
.default_trigger = "default-on",5 }$ `, z1 F/ X, |
},7 }% j+ m8 m G+ L/ \- B
{! Y/ o1 E0 o, z8 S3 v
.active_low = 0,
6 k! U$ K' M9 b .gpio = DA850_USER_LED3,+ y; Q8 a' }) \( r
.name = "user_led3"," x4 N6 k3 W7 K a. d9 M
.default_trigger = "default-on",
" K+ r9 O' d% @( L },; O# O3 b9 k: l* E( I
};% h; r. \' N8 E7 ?. z
' f5 J! c% C8 h) z$ r; X% ?- x: estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" {' S& e. `! b: z2 t# n) |: b .leds = da850_evm_tl_leds,
+ g3 `$ j5 d$ ~2 N" u( u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ s* B2 y6 |# }4 u. I};" ^2 l3 p# V$ x! u
0 s3 _4 L, i$ z) e& Z* v: {" ~
static void led_dev_release(struct device *dev)
! @+ e1 f9 r- X9 v; G: f{
$ d% A: f$ x$ t# `};# y6 ~( i; S5 _ }2 d
+ d- v+ Y7 B4 F+ V7 _. vstatic struct platform_device da850_evm_tl_leds_device = {; ]# E7 ?% D0 ?6 x' e* o
.name = "leds-gpio",: X0 _5 A( \: t! q* i- l
.id = 1,* d3 l; V8 P2 \/ p' D
.dev = {& v! G, V% X7 B3 x) X/ g' [
.platform_data = &da850_evm_tl_leds_pdata,' A; e6 `6 W7 g# H+ Y
.release = led_dev_release,
9 b6 c* S4 s2 L9 t- ~2 C }
5 d! ^3 P" F: P6 T};$ N e$ u! x/ o' e
2 z# S: G! L1 P: J5 j
static int __init led_platform_init(void) W* P" n: R) _0 P! i& F8 `
{
% Y1 g! e8 [8 n j, e int ret;
' S; I2 \4 K! Z' Y! D#if 0
4 ^/ O' n+ V, @; U. N( r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; A ]0 Y' Z0 N6 C! J if (ret): ^/ ]4 w5 [' U: i7 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ k Z" E( W2 D1 I "%d\n", ret);
" a9 |% |3 l2 W Y# i# R4 k#endif
# l1 A. @4 g9 a/ L, e- w+ x5 ~ ret = platform_device_register(&da850_evm_tl_leds_device);
2 o, Q! Z2 Y; ? if (ret)
8 B- c1 o* H5 Z% a pr_warning("Could not register som GPIO expander LEDS");3 E; s. B$ y$ \
else$ E3 z: F4 ], m* t- |, `
printk(KERN_INFO "LED register sucessful!\n");8 n0 z0 @. b. i9 E) r( L$ |
0 b. S% I! a6 d4 F3 M return ret;; v6 Z! F6 a; b
}
( N$ b, h5 h5 k4 [( X" L3 `
; X* Z, o1 Q& ]* p" k2 I' Bstatic void __exit led_platform_exit(void)
# `9 b7 W2 J* y/ e{
7 O( h% I/ f- R2 P1 V platform_device_unregister(&da850_evm_tl_leds_device);
7 E" @8 i/ a% P4 g* ^9 c3 r- V, ^0 ] k9 e
printk(KERN_INFO "LED unregister!\n");
* }0 Y7 R' D/ v1 n5 ]}
& y" D! z" _& ]( d. x
: Z2 a9 p+ D! G. pmodule_init(led_platform_init);" X$ g# z$ k7 o" F& u
module_exit(led_platform_exit);
_0 T' T# Q6 {/ g P8 \. y/ a( n, L8 j( t6 d
MODULE_DESCRIPTION("Led platform driver");
5 C9 r1 s5 ] q, |( K/ BMODULE_AUTHOR("Tronlong");
# k. O+ M( b/ w& _# s9 f7 KMODULE_LICENSE("GPL");; X. s, ?! q, x. q e; @9 K9 E
8 y& w" B3 u8 I7 \
|
|