|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. h9 n+ ~- x& m0 L
#include <linux/init.h>
0 d$ X+ s) W) i* v#include <linux/module.h>
! w3 r' K* ~3 K+ m#include <linux/kernel.h>! r! k; Y3 }+ @% R* ~+ w1 Z m# M
#include <linux/types.h>4 k. x5 X3 L( J! C4 I3 y
#include <linux/gpio.h>
: L# f3 W! ]" J( d# _#include <linux/leds.h>% W- Q4 K3 D- p! h9 O
#include <linux/platform_device.h>
. I, C' c l( M/ X1 s7 Q8 J2 J) y. v# K( g: p# E5 m" @2 M+ o; M
#include <asm/mach-types.h>7 i& e8 i0 `6 @5 I$ s
#include <asm/mach/arch.h>9 m3 ^3 w- B8 A6 w
#include <mach/da8xx.h>6 ^- J9 P* w, [+ i9 \& X4 m3 \% q
#include <mach/mux.h>: Y7 T# ?" m# I% @1 Z
* F1 J3 m4 `& n! H9 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), Y9 ~+ W4 V! p: H. i1 d+ T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' i# g1 c/ V! H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& _: X) a' w' H" w$ y; z2 G/ q- `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 O1 j' M/ m( Z4 B7 P- {; v0 \
' K7 k" U/ I3 }+ l/* assign the tl som board LED-GPIOs*/# C6 v. G Q& @( y' Q
static const short da850_evm_tl_user_led_pins[] = {
. e" ^7 q2 X% [! i, y, L% v" f& n /* These pins are definition at <mach/mux.h> file */
' Z9 L% ^) N& ]1 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# s5 O2 X g: m7 t/ p/ p
-1
! {/ c" m! i' v) s};
& Y2 D# a; a0 w3 o. K F3 Y8 O) K8 a3 Z1 F1 J# y* K' g
static struct gpio_led da850_evm_tl_leds[] = {% p3 g' Y& m9 w" f! r9 I
{
$ K( ]# E8 o8 w A0 Q& o .active_low = 0,
# Q W0 Y! n; G1 `( m0 ~, z0 o- z .gpio = DA850_USER_LED0,
) ?- E# j* j. [. E3 Y .name = "user_led0",
( t; V! h, i7 t% {1 p- j .default_trigger = "default-on",! v) y1 x( {8 e+ h1 `- {
},
- f- D7 N0 ^% E8 M# ?( f2 [: E {
; R( f7 n+ n, J/ y7 j$ a5 v .active_low = 0,) w: T+ @7 b" G
.gpio = DA850_USER_LED1,
' X" M( e# b" a0 K1 t .name = "user_led1",
+ ]& p' M# h j4 }, M; T; a) S .default_trigger = "default-on",( @# ?1 i$ ~# _' W! _: e
},, i, E1 T& f! r( ^7 `) ^5 B# d
{, L; Z0 j1 V, b' M
.active_low = 0," E/ ` g) @) K1 C
.gpio = DA850_USER_LED2,
9 m P( B4 d. {5 r .name = "user_led2",
. t+ \6 O* A" N& d K2 w$ U .default_trigger = "default-on",
) S6 w: L! {* W0 x },
; L1 D- o9 E) u5 v. g2 O {" f( Y$ @6 t& }! c$ O5 v: C9 @( B
.active_low = 0,: S: s* c- v& t5 u" \
.gpio = DA850_USER_LED3,) l- U' C3 ?, u' F: `
.name = "user_led3",. D2 H; O; ]; x L7 J- Z
.default_trigger = "default-on",
" s/ l8 C$ ^* o1 T6 v/ J },. z9 K8 B2 y g. z, d3 C9 S
};# Z/ J" \1 x n7 }% R
, ~6 {" t) a$ G+ s' k% ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( w2 b' W8 N2 G. c* q5 F* _" y+ q' p
.leds = da850_evm_tl_leds,
7 L+ N$ A3 j X4 t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ W% N6 @+ A0 k# U( r$ U; ]};$ q( H: z9 P: g9 [: b- s
+ K; |* H3 }1 U" pstatic void led_dev_release(struct device *dev)
! o. {: q/ \- L Z{
, ]2 r* ^+ j8 r/ k1 x% T0 X E};+ I$ P1 t1 F% H) i, V1 r& K
* H8 J) _1 r. s% J% r
static struct platform_device da850_evm_tl_leds_device = {3 q7 U" c' P& a
.name = "leds-gpio",/ [3 ]1 }: _& V1 j4 k8 d8 f
.id = 1,
$ W! P$ y2 V1 n .dev = {
/ |9 q. a6 T+ D* V+ M0 k .platform_data = &da850_evm_tl_leds_pdata,' x/ }- n& B* @. ^
.release = led_dev_release,
6 N5 D# y# U$ k/ I }
4 _" d1 V+ O2 ^. F6 ~4 o};
8 H- ]" J, s, S0 n# m) v: _6 w
/ Y6 ]; B8 C, R. G5 U. C, sstatic int __init led_platform_init(void)
" o" g, l0 m0 J" F1 a{/ I$ r; j1 d1 X& x. [
int ret;
1 I# T# D" l' u j3 g: h#if 0
) G: {! N2 \7 W- e, v6 w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% A3 a% S/ I+ _0 a# T if (ret)
# H" q8 z7 I4 q. h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ P8 s. I/ X; w "%d\n", ret);
& J' a" M- v) z% C. z#endif
8 A! ?0 f$ N! E# x. O ret = platform_device_register(&da850_evm_tl_leds_device);
4 U4 e; o/ V3 p: y if (ret)
( Q6 U, P3 q8 @6 ` pr_warning("Could not register som GPIO expander LEDS");2 n# j7 z% t8 I. r0 T
else
$ R' D: }% n9 L; b9 p7 H printk(KERN_INFO "LED register sucessful!\n");
" I! c' \) E( N/ Y
5 V) N" Y: I4 O+ ^; ]6 ~; {& p: V return ret; @" b) _+ _# f; i% g! i; A
}
& S0 O% A' h: M! b0 ^( C, `4 Y# ]2 {' K. P+ I
static void __exit led_platform_exit(void)4 V- x: U: m7 P8 H+ ?
{
6 {% j# n& [' P platform_device_unregister(&da850_evm_tl_leds_device);2 u8 R, Q8 j- Q' i5 r( H
3 |6 Q+ a' j( a% w printk(KERN_INFO "LED unregister!\n"); E+ K: h* p) s7 D/ u
}4 {$ V9 @5 E, i: j, v
* A1 I, C' g2 L+ U1 Jmodule_init(led_platform_init);/ t. m- a3 d: w+ U3 ]# Y) H
module_exit(led_platform_exit);, `9 u/ s4 x' V! ]: E
1 F: I" x( X4 C& r: A( @) wMODULE_DESCRIPTION("Led platform driver");, I1 U* H1 g9 Y" ]2 n
MODULE_AUTHOR("Tronlong");/ A l# y/ O8 d" D
MODULE_LICENSE("GPL");; ~9 {$ p* Y' @& T: |
+ Y+ a+ U: {+ ^9 p |
|