|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& R! l1 [# J0 U' g
#include <linux/init.h>: Z% t7 P# v- b& k0 X H) T# q# \
#include <linux/module.h>
: G% V$ B2 q9 a' b' [$ {#include <linux/kernel.h>
; S" Y1 C) [. ~" j/ S/ x2 s#include <linux/types.h>
8 }# J" l& Y" x( }0 @1 c#include <linux/gpio.h>
: b6 [8 D* j1 K8 a#include <linux/leds.h>
. M1 D9 x, L, t# T" B$ o1 b9 k/ u#include <linux/platform_device.h>) j3 W+ e3 f- y {% H2 o; Q9 J! y$ {! M
: o: o1 T0 \+ S, r( l: J2 f( p
#include <asm/mach-types.h>
4 ]$ X6 v; p4 j" x* }6 D: U& s#include <asm/mach/arch.h>
# t5 R& ~7 d& j! O#include <mach/da8xx.h>
0 B1 V) a- _6 Y: b: b' @#include <mach/mux.h>5 F" m7 ` P& D: k( h
b* |- c- c/ n V. }, v( t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 Q2 Y& i: `; Y8 i# {7 Z+ `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ J" ^9 r$ u, Z$ T* n) N2 s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 F2 S( f, x# N- _7 `) A4 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& v. z* A# ?9 I$ y' v+ N
6 |$ v! t) X3 j; n0 ]2 f# t) A
/* assign the tl som board LED-GPIOs*/3 c6 R9 @! a. Q) Z# Y
static const short da850_evm_tl_user_led_pins[] = {
/ z7 ]$ D7 w( o6 u /* These pins are definition at <mach/mux.h> file */
2 Q3 b% b' S H: V8 Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ~' b \7 { @ -1
, f7 }9 h8 M4 {; a2 s8 c};# r5 U3 I3 G9 @# ~' \
8 ]% J2 I$ `6 Q( qstatic struct gpio_led da850_evm_tl_leds[] = {
9 Q' t1 U# @, t+ ~ {
6 ]$ X! C, R% V# a .active_low = 0,
% G5 t1 Z4 ?3 S$ e: z" k* C .gpio = DA850_USER_LED0,$ P; B% i4 Z7 n, r6 j; Y
.name = "user_led0",8 V7 a) o8 B2 ~2 b+ o Z4 o
.default_trigger = "default-on",+ A( u8 X" b. p% T4 Z5 m Y3 c
},; T2 G& N4 l+ F W
{
1 y+ G1 |& s7 M: E# K$ x .active_low = 0,0 ~4 Q) N' t8 ?2 {9 Y1 I0 S
.gpio = DA850_USER_LED1,
6 d6 r5 e2 ?8 P. h; f$ i6 {$ ] b .name = "user_led1",: c: F: {$ F7 n- x
.default_trigger = "default-on",
% p, h% U) s; E/ b9 g },+ b3 G: ]# p$ u! b
{1 u6 @ w2 c1 o9 _/ P2 X
.active_low = 0,
5 {7 w4 Y" D8 W .gpio = DA850_USER_LED2,! Y3 b( R/ m& ?% r h7 z6 y
.name = "user_led2",, m% m* ?6 |. ]6 v3 g
.default_trigger = "default-on",. X- {3 m! f4 h _
},
. |+ _4 {4 H1 t1 |; [* n G2 C. N {$ j4 p1 ~# q# u
.active_low = 0,$ c, p, H" u% _
.gpio = DA850_USER_LED3,! [6 M! J) `. M9 v7 b0 y
.name = "user_led3",
+ \. Q K6 l/ d+ t2 T .default_trigger = "default-on",
& Q A3 F; e3 R: S },
; g' K5 U3 ?2 i};& p# q6 x2 Q$ Z9 F* P
' Z; c2 I& G1 R, u1 V; V1 |. ]. X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 V0 O9 i. F2 m5 S: r .leds = da850_evm_tl_leds,6 A: `# C1 W7 E% e# f/ z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* z1 D% H8 f. {1 H7 O: A- x% c
};
1 r4 x% z! J: |( w
( ?( h& ?; J4 Q s! I: q7 F; astatic void led_dev_release(struct device *dev)
9 H* ^0 `# K; g, W2 d$ h, a+ f{& F% k# S5 C( _' d. K2 c$ u
};
2 d9 D$ a4 c- L. ?: u* @$ j& F8 [. ?8 E, Q. O# L$ G: P
static struct platform_device da850_evm_tl_leds_device = {5 \% d3 S% ^9 O: F
.name = "leds-gpio",
1 D$ E/ [/ v/ w4 w6 Q' X! |6 m" x .id = 1,
5 u: T% w z9 L0 P2 K .dev = {3 H: O+ r. z2 I( d& u3 V2 a
.platform_data = &da850_evm_tl_leds_pdata,
r+ Z# U' L) M. M2 j& x .release = led_dev_release,
( @. }7 b8 J2 E; T. y1 T }
& ~1 `9 V- h2 X% q8 u};
6 E" C8 T/ J( ]# e
e( }1 S W; t7 \static int __init led_platform_init(void)& m( `1 i. q5 h: X
{
1 c/ W1 i; t! x5 e0 Q4 W4 W3 P int ret;, Z) P& j+ B* Z3 s) Z
#if 0! ~" u6 o8 d F' |3 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ y/ x4 Y; M3 U2 ?4 N0 G7 [
if (ret)
& q2 r9 S/ t+ t- T% I# I3 l- y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 S; i5 X/ m5 @7 ?7 _0 [
"%d\n", ret);; G# X2 p- g5 a8 g6 i4 Q) |
#endif
, \5 J/ N' v9 i2 }) `7 p ret = platform_device_register(&da850_evm_tl_leds_device);
1 Q& \) S3 d+ |, X! b9 D# b if (ret)
% a; N! A4 S. i! c pr_warning("Could not register som GPIO expander LEDS");. Q6 e- X+ T8 [, i% l
else8 {& g& @$ E. J5 `
printk(KERN_INFO "LED register sucessful!\n");& \: r5 |. y0 J+ H4 P3 E
( s+ S( ^9 V( C- N! X7 D return ret;
/ ]$ f/ o- H% f( `7 a5 |" B: R}
& [: w3 c" l" u, P# @
& h* b9 d- V) ^# o& p4 \static void __exit led_platform_exit(void)
4 y1 ?7 f9 f2 _2 \6 m% h5 V" U0 W{( u! O, P! l( o7 H
platform_device_unregister(&da850_evm_tl_leds_device);9 Y8 H, z- N9 ]# ^' h: Y
; O- S# v- C; o
printk(KERN_INFO "LED unregister!\n");
8 ^7 h$ V% Q; o% p- F) g}" w2 R3 }( W) N1 Y6 `. [
& C! s/ w6 w7 e8 P3 X. \" q0 Y
module_init(led_platform_init);
8 [0 X9 W: j: u' c3 }; k" Kmodule_exit(led_platform_exit);
6 M( S4 p* o" U* f# F3 A% @6 l: l" t3 Y/ E2 L1 {- z# }6 B, b) _
MODULE_DESCRIPTION("Led platform driver");
- V' p6 U* Q3 ?; c$ k; rMODULE_AUTHOR("Tronlong");
+ A$ }3 u, A! k m! I& F( GMODULE_LICENSE("GPL");
* q! l7 r. n: A- S1 l- e y6 E
1 L- n" g7 D, j |
|