|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) g# [9 j4 `0 q8 P" [
#include <linux/init.h>& w }9 [: X; f( k
#include <linux/module.h>
1 T5 `: H/ i# ^#include <linux/kernel.h>
4 ^4 `4 s0 t) m#include <linux/types.h>
2 ^/ ?7 W3 E; G+ m- d#include <linux/gpio.h>, u, X8 ~! K4 e% v
#include <linux/leds.h>% k$ x+ J' J2 I* S2 A) E0 ?
#include <linux/platform_device.h>% Z0 I2 I; s7 T0 r
. A, H/ a. T8 x0 t' b& v
#include <asm/mach-types.h>
6 }& [* L/ l7 B- d9 I6 ^* T#include <asm/mach/arch.h>
]) `, I. b2 \- O9 d8 b#include <mach/da8xx.h>% j' L6 b" ~" C: ?5 E
#include <mach/mux.h>0 W$ ~8 C0 U% ^& f1 m& k; {
2 F0 B# |$ @ C. K }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" e @) M& g1 Q9 s" D8 y; ^$ E# X! m" u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 P, T# k) J9 { P+ k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- ?. R' P' j: S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" s: B8 l# k0 `$ n- H4 x$ _' ]0 c K
/* assign the tl som board LED-GPIOs*/3 z* r2 x+ d7 H, n& q
static const short da850_evm_tl_user_led_pins[] = {
; y5 Y6 _4 J1 M8 c2 E /* These pins are definition at <mach/mux.h> file */- [: ^% `5 {* t' S8 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# l- [0 O/ w" k4 [5 ^' C" ?( P -17 X$ x0 I8 }; i! E* s0 _3 y# ?0 N
};
0 ]/ P8 {% u, I3 y4 @8 B1 ?) b5 n, h9 G
static struct gpio_led da850_evm_tl_leds[] = {( Z$ Q W6 q( B
{ J6 h Q2 h# `0 L: h' z) s* J5 [
.active_low = 0,
( c0 l) x; {& w: P .gpio = DA850_USER_LED0,
f: ~9 n& \% y3 P7 f, N .name = "user_led0",
7 u4 D; }' w* e/ g# c' t .default_trigger = "default-on",
' Y0 W k( G7 }: b9 S },
( ^+ ]+ B7 e) B' g: S0 z$ W! e9 N {0 r# G6 Z& `1 n2 r J# `
.active_low = 0,% L, ^* C" @- v
.gpio = DA850_USER_LED1,7 u* Z1 n z; Z ]3 [) K9 }2 i) Z) t
.name = "user_led1",- r5 D. ?0 ]! x( V4 N& J) x( g
.default_trigger = "default-on",
0 q) W _( u" k) r }2 [' o3 ]2 | },: q0 s+ B. e, a
{ Z( T, x G9 ]- w! m3 w4 \
.active_low = 0,
4 I, |2 G3 H9 P, e. H/ M# u+ u .gpio = DA850_USER_LED2,. { d) \8 P0 I2 q& g2 V0 [( K5 f3 c
.name = "user_led2",6 c( e2 T' p( \
.default_trigger = "default-on",
" B! t/ y6 D# x6 \7 M# B3 T! a4 O6 z8 G },# q! k7 q U( [; J/ c/ C
{6 ^: R1 K* V: A9 i* O2 K, E) K
.active_low = 0,
/ d3 p2 P% ]7 G7 s7 _$ m .gpio = DA850_USER_LED3,% ~, D: l) i! e
.name = "user_led3",
4 Y; S& n/ [8 o4 {' S% R3 O0 s .default_trigger = "default-on",
- W+ s$ U6 t, `1 N },
5 T$ L d) {7 H. _" l5 q};
# m v( l# t0 j, n, }6 l8 c# N( r: M+ Q/ S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! p: H, p7 H( ^/ Q) c* T& d
.leds = da850_evm_tl_leds,# S* \4 `) {. |$ o$ _) }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 \5 A% b0 K& _4 b};* [- f4 M! L- S& N0 q& P; n
% p" F, x, g# _2 }static void led_dev_release(struct device *dev)3 [, Z5 d! c3 T* J
{
/ o# P4 v' R: M4 p: d: w9 t};
1 A3 a1 r4 N' C" j
9 G/ [( H# r# a) Q& Q4 Zstatic struct platform_device da850_evm_tl_leds_device = {
; b$ ~( {2 b) s- H* S& x8 O3 K8 Z' g .name = "leds-gpio",
! K9 v, H: u5 n* I' _ .id = 1,9 j: t9 z& ~9 U! x
.dev = {
; m- M. V# q; k .platform_data = &da850_evm_tl_leds_pdata,( u+ i* t5 ~9 b) H5 M2 \
.release = led_dev_release,8 B, U3 E0 X% |/ q- M1 ]3 N1 _
}
7 T6 N% S) j3 a4 `};
' T. l j+ P, y! v0 j* J7 q2 ~' k1 y v9 g5 S0 Z: y8 ], J
static int __init led_platform_init(void)
7 ~' H4 S4 J4 f5 _{; g* O& j4 K* T- a0 j' ^7 e
int ret;
& U9 E, m+ P/ ~; A# j0 Q#if 0
. ?$ s' \; L! I! D1 b" a5 u/ ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( I& N" d2 M8 `/ ?' S X# } Y
if (ret)
1 |; x \9 `2 [4 |; ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; _ g+ I @+ z _' n
"%d\n", ret);1 d0 e9 P: N$ f \2 N
#endif1 a4 g z5 V4 L; o! A' u
ret = platform_device_register(&da850_evm_tl_leds_device);
: T; l" H/ L+ Q5 p3 U+ s( C7 U if (ret)
" d' a6 j( e0 |" j- x: @ pr_warning("Could not register som GPIO expander LEDS");2 j! i5 L& N) a# v
else
9 E4 S! h+ j. k* S printk(KERN_INFO "LED register sucessful!\n");$ @( |, ?' [; C a3 u
7 u8 `: r: }5 U7 j
return ret;
) M* D$ Y {# Y6 C/ u7 f}& h7 D. d, Y6 o# |* l2 a/ w
5 k3 t) |$ o- O# j2 estatic void __exit led_platform_exit(void)+ R& c* ^% e: I( D4 Z/ j6 g' W
{ A( p. Z8 a/ K- u
platform_device_unregister(&da850_evm_tl_leds_device);6 W+ g6 s3 d' ~0 e+ t% Q) Y
5 W$ m2 ]+ e, o
printk(KERN_INFO "LED unregister!\n");
- S0 z9 [5 a; R* k- w9 I: U9 C& ]}
8 |; U9 u( n. z
( r5 i$ Y9 E5 x) k9 ^module_init(led_platform_init);( T( y- Y' j0 @' [3 I" b! y
module_exit(led_platform_exit);
& Z3 G z3 M2 C) I* r6 T) z: q/ A# j3 R/ Q5 ], O) t
MODULE_DESCRIPTION("Led platform driver");! O6 z- L& u- G9 ?% C1 r7 ^
MODULE_AUTHOR("Tronlong");
$ ?9 `! U9 P u6 o8 [# r3 b" ~$ F& NMODULE_LICENSE("GPL");
7 L* n$ M8 e5 ~. Z+ S) P2 o" w; Z" H( _5 Y
|
|