|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& A/ r3 [: ?% U! e# M* ?2 J
#include <linux/init.h>5 u6 _0 q, J. S8 k8 O; V
#include <linux/module.h>
3 z' T# d0 d' s0 P9 @) R6 \#include <linux/kernel.h>' Z6 e c: Q3 C
#include <linux/types.h>0 x' k- \& a. O! V
#include <linux/gpio.h>% ^' b: y& Q; j4 R: K( W
#include <linux/leds.h>/ y( c2 z' K5 p' l3 O/ u- A2 }6 h( p
#include <linux/platform_device.h>
8 D }% |# w! W5 @- [! m% T D
% N- {3 Y0 m- [* n#include <asm/mach-types.h>1 z5 B3 c/ t- h
#include <asm/mach/arch.h>
9 G# s2 g$ j0 d( N#include <mach/da8xx.h>
1 w; q# e' i& H" ]# Z9 B#include <mach/mux.h>
3 r# w: O7 W8 o& P; ^5 N- w. R( S" I
* B ~) d- K7 A U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
^" F* T; P# t, z; g2 Y9 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 V8 ~! e# B$ X2 q! L; e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 W. ?" E0 f9 p, R5 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% A4 |. Z" \. G& s. w' k" i
7 `: u+ ?. M3 a5 U2 g, }* ?1 B
/* assign the tl som board LED-GPIOs*/
8 s- f" k# R; ostatic const short da850_evm_tl_user_led_pins[] = {3 `. S: i& }0 D0 {' I- U
/* These pins are definition at <mach/mux.h> file */7 Q- k( t, I$ N4 j- l" _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 B0 p; m* ?! {; ]. J- o7 D0 h* ~( P -1) Z9 Q; k- r2 f9 _ c
};
& u1 B* |" J3 V( [- l/ t% l, U( Q; v2 ] O4 k9 u& z
static struct gpio_led da850_evm_tl_leds[] = {3 X) m. {! J" D) U
{
* s! N. t, @' f, w2 @ .active_low = 0,
% L( m( b" p/ `( x) I b# M8 { .gpio = DA850_USER_LED0,
+ D; D; ]6 [6 Q3 A7 s$ S .name = "user_led0",
! J+ z/ H0 W4 z5 c+ Z1 U( `/ g4 @ .default_trigger = "default-on",! N# T( S: A( `) T# C
},5 l( P$ g! ~" M4 G
{+ n. ~' }6 @2 j
.active_low = 0,
w, L+ T5 [4 J. @: ^- q p8 [ .gpio = DA850_USER_LED1,
) K/ a# }' o! k$ ~6 { .name = "user_led1",
, _' I9 U" A4 ~ .default_trigger = "default-on",
) w1 p9 w8 v* R3 l/ [# S, s9 Q },
5 y: |4 h: U7 n$ P {
9 U) v. |& u) g6 e! W .active_low = 0,& R8 ]6 h+ G; E, |2 _! _0 r7 W
.gpio = DA850_USER_LED2,
2 l3 p' I/ v2 J* _/ M .name = "user_led2",' S$ T: }6 s, |: k
.default_trigger = "default-on",
1 q) ]: E# ]. Z2 I( l },
! V9 c0 V" I/ Y: B2 l+ G {% A! `$ P% J0 W7 n, j; ^: J
.active_low = 0,& J/ D# s& Z* B( J* V8 b4 e
.gpio = DA850_USER_LED3,9 J8 U# [$ ]+ f& l: h0 ]! G: v
.name = "user_led3",- o3 w8 z) |1 E4 _
.default_trigger = "default-on",
/ l: z; `4 D9 {7 M1 N },, H+ J$ Y- e) F) W9 Z* Y2 o
};$ S8 [2 D, s: S
- K- r5 o3 Q5 M- K) C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, U4 J' A9 o0 x
.leds = da850_evm_tl_leds,
& s, }6 g* i8 Y- K. q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' P' o0 A }3 H% I; g6 M$ w* Y4 ?};
% ` m L4 P5 {8 O" D$ U. H/ d4 B4 D' _& b2 C1 d
static void led_dev_release(struct device *dev)
9 z% B4 b( B' W% F6 U+ |& _{
& F: O7 L5 C6 U2 C};
# d& ~7 D8 R* O( r2 e$ v3 g5 O0 i( Y* t7 x: J; Y* ^0 ~
static struct platform_device da850_evm_tl_leds_device = {5 ^# e: v# a/ k B" p
.name = "leds-gpio",
' u% L# R1 c# r* C .id = 1,
+ x6 W' R$ _' `; k; v .dev = {
- q% G7 d: G3 a2 w$ L0 R' t5 j! E .platform_data = &da850_evm_tl_leds_pdata,( |* [- C$ [/ l7 D
.release = led_dev_release,' C, \- v& Z. c8 Z' e
}
/ }# n( s- [! N+ M! V. D9 F- ]" t};- K% Y. n* J# D8 r" j
9 p9 F5 C7 f5 [static int __init led_platform_init(void)
- R- O/ R. K7 _, V{
/ W' t1 J4 X$ `( @+ I' Z, x: e int ret;
6 j3 i; [* e% [! }! \( E3 Y#if 01 \% H3 u6 a3 ]5 c: D% o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 d3 Y) o! U- L+ z if (ret)
3 }0 i' V7 H6 B0 v3 F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! I0 ^( ]' D( s3 \. z' ^1 T4 [
"%d\n", ret);3 u$ K/ U6 s3 k) A) R% p+ L
#endif
4 N- ^9 l! z! h* E$ b8 S5 ? ret = platform_device_register(&da850_evm_tl_leds_device);& E* v9 g/ P! N! \* |5 p! i! ^
if (ret)( v' v& G" g4 }. q* f
pr_warning("Could not register som GPIO expander LEDS");. R7 y$ x& o7 ~
else
/ D/ M( S; B5 ^3 n" c printk(KERN_INFO "LED register sucessful!\n");9 C0 }) o4 P5 N
& P6 U& n5 w5 ]3 V. Q* t7 c( _ return ret;/ e! _2 R; v- X: e- `
}
% r1 B. l; |6 N; f
, e/ @) I2 D/ I* N' K) Cstatic void __exit led_platform_exit(void)
; b1 a8 R/ R1 g& [5 C{; v4 T. @* c+ T) H5 i' \
platform_device_unregister(&da850_evm_tl_leds_device);
5 F- E4 e% d7 K! o$ C
5 B6 S3 _( H2 i' y* ? printk(KERN_INFO "LED unregister!\n");
+ d, G. D5 U6 Z( H) I9 E}
/ X+ ~/ ]" d! a5 W. S5 {# a' c2 E3 K6 X7 p/ d: m1 l) }7 s/ P/ V
module_init(led_platform_init);; T$ c. U# M- S9 U- a1 @
module_exit(led_platform_exit);
% e3 [( d3 ?# k: G3 ~; e0 Q
& [2 C( I6 ^& C' G1 |4 D) Z* MMODULE_DESCRIPTION("Led platform driver");
9 P7 K! n+ p6 A1 b5 ]) u1 i$ E1 YMODULE_AUTHOR("Tronlong");
7 I+ q7 m4 z" \8 ~. a8 r/ d% IMODULE_LICENSE("GPL"); |& r0 J* ?2 d5 B
7 B" @8 _5 R) X* ~ |
|