|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 f! W8 ^0 e& ] P/ `
#include <linux/init.h>
( _& A! Z/ {( y x#include <linux/module.h>
4 S G4 g$ p/ g#include <linux/kernel.h>& ^! B m# U! i& d7 M! y! @9 h6 A
#include <linux/types.h>
$ ]) ^( \4 r& W5 u8 Z8 r; Q#include <linux/gpio.h>
( t' ], j H! f5 {# J#include <linux/leds.h>
+ c* r1 t' ?8 L+ Y# y6 m* C) u#include <linux/platform_device.h>% K0 H. S3 [. `4 X# O+ ^5 X
4 M, U; l; K7 s, ^& |# q
#include <asm/mach-types.h>2 O! I5 Z; v0 Z# n
#include <asm/mach/arch.h>
3 T* N/ w% l: ]! M, ?9 l$ K#include <mach/da8xx.h>
9 H5 T: R* _+ B+ L#include <mach/mux.h>8 d* @& ]# k( ]% |
+ H# }) O0 _% j/ H0 K. Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 S& Y: ^) c/ k! Z, ]$ d# u9 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( G& \ M1 S- q1 t# m7 I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 R/ I$ E0 A# `* i* d" w( n; X0 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- c: j$ g/ c, ~- y; J9 m
! F* G8 c7 I( Q1 C/* assign the tl som board LED-GPIOs*/; K. B# x! R7 I9 q/ A/ j9 Z
static const short da850_evm_tl_user_led_pins[] = {
. q' C$ W/ c! X) K /* These pins are definition at <mach/mux.h> file */
6 W- Q* i! r& _- I" A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- N$ z9 L' U1 _- o, W2 `- R% f! Z
-1
" I4 F* Z1 ]1 g r};4 }. u0 ]! P) X. v, p2 m
4 t: ^: B; v( b, m$ \. T6 q; ustatic struct gpio_led da850_evm_tl_leds[] = {' U( B _* F0 u( \
{% u) f; R' v8 b7 }: a' k$ i
.active_low = 0,
# @% r) S x: U& [2 l7 H) \7 z .gpio = DA850_USER_LED0,6 i `! P# |* V8 J V0 s$ g* |4 l
.name = "user_led0",, b$ f+ u& t5 s/ |9 y. e
.default_trigger = "default-on",, W# R: l- Y. o* l& R* S$ K% g$ ?
},0 X! b& p7 x! s
{* a/ b8 w/ p4 h" }+ Y1 O; M
.active_low = 0,
( j" D) M7 q! H2 @7 F .gpio = DA850_USER_LED1,
' w2 L6 w! o' E2 I4 s* P .name = "user_led1",
' |' Q! f' n. j& Y .default_trigger = "default-on",3 Y% c& S; N/ S' r% N, \
},
" N F4 x/ G- t: ]2 H {- S" A. {" H2 D9 l h
.active_low = 0,6 {5 H. j6 g& C& R' |9 {1 h# a2 ?7 i
.gpio = DA850_USER_LED2,, U1 A- d$ y9 \( w8 D
.name = "user_led2",
/ O6 K' u3 }0 w7 T$ a2 |' Z .default_trigger = "default-on",3 ?; K) ?. j/ x8 h9 \6 u- N
},& q+ v7 ~2 O# b9 s5 y8 T+ O) W
{+ O# Z2 s$ z7 S1 i* T0 W" V6 }! o
.active_low = 0,
2 i2 @. R- J7 T0 V- \3 {6 u .gpio = DA850_USER_LED3,
& H& J$ u# k1 a$ r& _( [ .name = "user_led3",
6 b# q1 n9 \, C: f4 {$ y- o .default_trigger = "default-on",
' g" I: Z3 A* T; \- } }, ]$ g- C1 h6 Q
};
; `2 G1 s7 q8 m, D+ S# m" s; M$ q' [+ x* o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# ~" c* H @2 |: x5 R: Z6 L
.leds = da850_evm_tl_leds,
- P/ ]# j z+ M3 v8 a* {& I9 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# I z* Q# r/ j$ Q; U$ \0 q};
# l. l' X. v0 r# @) }
$ V3 R' A& r, lstatic void led_dev_release(struct device *dev)
: K/ l$ \4 n: Z9 Q& O' d! [- }{7 P0 I: W8 s v$ ^ U5 Y5 j7 `
};
7 |7 t; c! B; @+ m2 Q2 W
; k( b& ^ t( h' G/ m4 jstatic struct platform_device da850_evm_tl_leds_device = {
( |9 d w5 W; X+ j" ?# k2 h .name = "leds-gpio",
( N; I" z: S) M .id = 1,
' M t9 r! t, U" F% J3 n# S3 q .dev = {
" s" D1 Q5 n- L% }0 z6 h/ { .platform_data = &da850_evm_tl_leds_pdata,9 v/ L8 f5 ]! {( U( }6 z
.release = led_dev_release,& O+ _+ a7 m+ _$ p4 K8 B9 F( b
}
$ V% n8 T; G6 B. q% W* v$ Z};) U5 U# u5 q Y2 m# g- U; S* b
( a/ `! k! [8 R; `5 W8 p
static int __init led_platform_init(void)# _0 H4 i' v& J/ Q1 b% m+ \
{
0 c2 [/ b2 ^% [) u( B8 p9 q int ret;
, J' V/ v( O0 N6 s! n#if 0# C e4 }4 |* f* X; L) d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 H1 K$ D* _% }- Y8 z
if (ret)
3 [! n0 y" B& S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) A( h B( Q# B% E+ U8 O* x1 s) ?( G "%d\n", ret);
+ z9 E$ U0 J- D#endif+ c2 {/ N9 c7 I2 i$ O
ret = platform_device_register(&da850_evm_tl_leds_device);
1 B" F4 G) Q( _ _ if (ret)
& Z! J2 Z6 w. I0 e4 @! E pr_warning("Could not register som GPIO expander LEDS");+ ]8 W$ i9 b2 b0 e7 B" s
else
1 s5 X4 K5 A! \% h8 b/ e printk(KERN_INFO "LED register sucessful!\n");
4 g# ?6 d0 n# B1 V4 w) n1 ~# r
2 p8 p0 t9 y# Z) G! M return ret;! U3 J, ^0 |9 m$ I( {
}5 `- U6 \8 `( W# \! B1 T
* e! _# k3 S. D5 L5 i) r1 c" v2 G8 bstatic void __exit led_platform_exit(void)9 B. M/ a8 d# S9 Y8 l! J
{! Y' t2 \+ r& C9 h
platform_device_unregister(&da850_evm_tl_leds_device);
r4 F! @- v, H2 z- l
; m+ `* P& b' Q3 } printk(KERN_INFO "LED unregister!\n");
% N5 y; z6 {! B4 z! K' z}( H' h |; m) L& I2 P
2 \2 o- y9 l: F" J, V' a; C
module_init(led_platform_init);
( R: c+ X& A$ p& Q) k! Fmodule_exit(led_platform_exit);$ Y; ]) J% h) o! V$ C1 d
% W4 h3 q0 [5 h' \9 X% s! E: V
MODULE_DESCRIPTION("Led platform driver");
4 U2 s! D) E. H' r) p4 TMODULE_AUTHOR("Tronlong");! j, d$ [, H/ p: @" V: { K9 D
MODULE_LICENSE("GPL");
4 b% w& D5 P: Y5 p$ p# G4 s: j
/ }, K5 e7 D1 y% i |
|