|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; p/ ]" r( S5 T8 |6 B
#include <linux/init.h>
/ V/ ~+ F$ E# S3 U2 `#include <linux/module.h>2 n. R7 L5 G' k1 S& ~
#include <linux/kernel.h>0 E: W; O$ @; O
#include <linux/types.h>
; G) T. ? h! b1 k( T' o" P6 r) V#include <linux/gpio.h>. v, b. E% z5 b: r: c7 }- Z, X
#include <linux/leds.h>
; _% v4 E! I6 C1 G#include <linux/platform_device.h>
$ d) J7 K! ~) ~( } ?. o" h" ?' h* }6 i9 W7 d7 X, ~3 ^
#include <asm/mach-types.h>. e( ]8 R8 N/ p K7 }1 f
#include <asm/mach/arch.h>/ I! V* W6 I5 }/ \
#include <mach/da8xx.h>
9 y8 o' q8 U: Y2 ^7 }: \% r#include <mach/mux.h>' |2 _& I1 u& m8 }+ R
8 |0 b- J7 N0 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# O# s5 q# s8 y8 i5 p% X( L, q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ g* D" }0 k8 ?' `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" }7 U1 r: s! N$ q% Y0 e: X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 V0 ~3 P& T. ~& k) G
8 c: i6 P; }& k% Y: {/* assign the tl som board LED-GPIOs*/
( Q* @6 }% r+ s Fstatic const short da850_evm_tl_user_led_pins[] = {
W" ?7 @1 B! H, r2 k7 Y5 V$ K /* These pins are definition at <mach/mux.h> file */( Y& [$ N" B+ x7 t P* d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" t' B6 _2 B+ A8 _" a/ `7 n -1
) f7 W1 T A4 {9 L6 @7 G/ k% @};) S4 F5 |3 k/ P) T8 _9 g
' [0 }/ n P' F% {/ {8 [static struct gpio_led da850_evm_tl_leds[] = {* E4 q* G9 v r3 d9 y
{
/ a! k4 U+ S$ }' z: ?# `4 } .active_low = 0,% A6 k# G5 k: A, K, c, g" m) ]# w& ?
.gpio = DA850_USER_LED0,- r: N& |, B. J4 O
.name = "user_led0",, u$ J; ]! Z$ B. ~4 m" @& M5 |
.default_trigger = "default-on",* s" Q( z6 ?5 H2 u9 J5 j/ X
},! X# B: U+ p$ H* T7 c5 v
{
7 V' _2 M/ `* f .active_low = 0,- ^- M8 @9 {' O+ Y, X7 m3 p$ ?
.gpio = DA850_USER_LED1,$ E0 p: S0 J1 X- Q' E. Y" p4 {- ?2 N
.name = "user_led1",
4 d4 p7 k1 K J$ J! A8 B9 b .default_trigger = "default-on",
, v3 }4 `5 j, W, k },) N5 B3 e% n& y l/ }' ?1 b
{
3 b+ V. M% O6 C6 k3 e! k .active_low = 0,- }- ]9 ~0 p4 k6 t' {
.gpio = DA850_USER_LED2,
F; k& A) z# I, n+ N: e .name = "user_led2",
* E$ e) l. {2 k, V$ a* H* e .default_trigger = "default-on",
, j4 i& G5 {7 E; P( X0 A7 f3 h },4 e8 b2 s2 t& J t- z, v
{
7 F$ U' E: H4 n9 E/ v, P+ ] .active_low = 0,8 }8 Q; L; x: t
.gpio = DA850_USER_LED3,
, B/ ?* e( d8 p; x; u/ g$ A+ I0 c .name = "user_led3",& H" d: e/ a3 Q+ p
.default_trigger = "default-on",
2 G) V: k$ e0 K! V },
: @% w! {, r( Q8 ?};/ R# j4 {- `! \# D" x1 s
$ h) f* c9 H$ T- j, mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ f" N7 o' Z5 L! b6 s8 P
.leds = da850_evm_tl_leds,
% A3 ?$ t; f+ y) ^1 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 k1 n6 t \1 P! v9 z
};" K3 l. Y- M% z
! o$ S; A: c- H2 x+ w# w. Qstatic void led_dev_release(struct device *dev)7 u8 o% w* X3 o* ]
{
7 ]- I8 E7 ?3 Z m. Y2 ?9 u& O6 \};3 H+ H" ]3 `5 I
& ?1 S) m4 C1 }- g5 hstatic struct platform_device da850_evm_tl_leds_device = {
* V0 W" }% J1 P) Q! w .name = "leds-gpio",' b6 ~( L3 S" N$ k2 w
.id = 1,
! d* Y$ P9 h& u: K .dev = {. r. N5 p$ T, g1 B4 O
.platform_data = &da850_evm_tl_leds_pdata,8 Z+ N2 h4 w: ]+ N% l
.release = led_dev_release,
4 K- k# }) _- m, a; ~ }
) L% i) t' E+ _; x};6 I" D3 p7 i6 j) P: v! G
! ]9 H9 A& b) R5 d1 A# T1 [, W
static int __init led_platform_init(void)1 E9 o: e" I9 r
{/ b5 n4 k7 O6 [, h1 v" H+ l/ ?
int ret;
) f: w) \( D- j. O( |/ W#if 0
3 X/ y4 \. u; M+ @3 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- S+ Q9 }, J% X. M& ^ if (ret)1 m1 D* i9 o6 c3 X0 b& H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& U1 Y& A3 h, v- U- ?$ c- [( M/ \# s "%d\n", ret);
: W% ^" P" G( v# q5 e3 E#endif
4 S5 M! q2 Q2 P ret = platform_device_register(&da850_evm_tl_leds_device);
! X* d* ?9 F9 j9 S' a if (ret); `" a+ h! @' [* o+ u
pr_warning("Could not register som GPIO expander LEDS");
8 w8 D. ~/ ]! k$ I$ @2 i8 l else
5 m% k& h" H h3 D9 ]# K+ A7 t4 h printk(KERN_INFO "LED register sucessful!\n");
. V4 y Z# O3 k' P" P6 k! D/ w% Y/ O; \/ t5 e- l
return ret;+ t* N/ v1 [4 k
}. U5 w# s e: @! D0 ^
- B( g; ]" q6 g- \& v# Mstatic void __exit led_platform_exit(void)
9 N" H/ Z; q8 s- F; {{
0 p6 z4 f" P$ i; p! b platform_device_unregister(&da850_evm_tl_leds_device);
8 F4 i/ k" ]' l' S b1 H
4 V) I' F, w# R m printk(KERN_INFO "LED unregister!\n");0 _# i! D) X& U( j7 J+ T" P
}6 |/ G; U: E; P+ S N) j
7 L. _1 {2 m- r# `: [0 U$ A
module_init(led_platform_init);
5 u" }1 Z4 s' u, smodule_exit(led_platform_exit);
% S8 d& _3 o5 T% E
* Q4 w0 V$ ~1 s& o2 D6 J. a6 _4 K. _- JMODULE_DESCRIPTION("Led platform driver");. d5 Z$ Y' B0 O j! S! x, T0 H
MODULE_AUTHOR("Tronlong");
" @' v( p2 E) Z" g2 GMODULE_LICENSE("GPL");
6 o: z$ H1 h" G7 o9 e
- \8 j: q& x! g* B- P; S0 L! t5 a |
|