|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- E. w& P0 F4 a3 E, o: G
#include <linux/init.h>0 p% j! ^7 b A q" Q
#include <linux/module.h>
# t, v' ]) _) j#include <linux/kernel.h>
3 T4 N2 w- ]0 y#include <linux/types.h>
+ V, E' D @1 ~#include <linux/gpio.h>+ ~6 o7 K& u: j. v3 ?" i. J
#include <linux/leds.h>, V1 B+ |5 P! ~3 V" Y
#include <linux/platform_device.h>: R8 T: l$ C( l$ [/ l5 U: S
$ r" f7 l7 C# z$ k1 \% j# O
#include <asm/mach-types.h>8 a9 [8 ?: d+ N7 f- A3 Y3 N9 G
#include <asm/mach/arch.h>- n. |$ U8 ?1 }: {* ^" K$ r$ t8 J
#include <mach/da8xx.h>
+ h) r1 x1 p, u: h) i% c! F) h5 B. P#include <mach/mux.h>/ U0 w$ v2 R3 E3 B- J
# @2 N8 X0 x2 O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). ^3 A1 B7 T+ ]9 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 H/ f7 B. ^- E, y6 H+ j9 [0 [) b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 \7 c9 M2 Z4 V: A+ K2 E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% W+ }- ]- n3 L, y" d. V9 C6 X; @7 C- ^2 c) \" b0 u0 F
/* assign the tl som board LED-GPIOs*// y$ h$ Q% R' g- v8 s. {' r
static const short da850_evm_tl_user_led_pins[] = {
m5 j2 g4 {$ T /* These pins are definition at <mach/mux.h> file */
8 E2 ^2 O" B2 n P4 C9 _' r* @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 _1 u5 ?/ E2 [$ V+ s h; `/ j
-1
( o$ [9 L k5 S/ M4 R1 X};
6 l0 C K0 {( k D$ |4 Q$ p% J! ^1 N4 T
static struct gpio_led da850_evm_tl_leds[] = {8 i6 H |2 J0 U" g1 s
{# [4 K; y# }+ A' J
.active_low = 0,
* P) y$ i/ ~, m9 |3 R .gpio = DA850_USER_LED0,
4 ~1 I; t: h. z |) Q .name = "user_led0",
3 A* f' H! A* ~+ I! g9 U .default_trigger = "default-on",
: B' y9 ?' m3 Y3 a },
: y9 ?" K! A+ Z- A5 [2 r- ? {# K, f3 T6 H( ^- G! P9 k* Y2 w* d0 u
.active_low = 0,
9 ^! ]. g9 t3 p. S' W" B" B .gpio = DA850_USER_LED1,
+ z3 H/ w% y4 n, X .name = "user_led1",
& l8 ]0 \5 W, x8 u' O3 Y9 B N% x .default_trigger = "default-on",% u* I2 K: y: f" P- H" R" P9 m
},
H& Q# w) Q* g7 G! u& o2 w {' |/ G x! B- [, q. ?
.active_low = 0,
* z8 S- U' M5 |% _6 H .gpio = DA850_USER_LED2,
" L8 p' C, s+ {" h) a6 _ _( l" G .name = "user_led2",+ p% a$ M O: d. g5 w+ A0 @9 U p5 S
.default_trigger = "default-on",
. B7 l/ a$ p: v: S. g },
$ E5 p$ s/ a, _ {
6 [ U' l* {6 k' Z6 W- ^ .active_low = 0,
' I' c% t4 v& c5 F1 r .gpio = DA850_USER_LED3,
& J8 C% S! c8 G .name = "user_led3",( f+ `, R3 d1 q/ S
.default_trigger = "default-on",
+ p0 Z% a% j% Y },$ K, G3 D! h* n3 Y( A ? M; L$ C( y
};( |; D2 ]3 y3 ^& J; E
9 n3 S4 D3 R1 A# x* q4 X5 u" T9 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# t+ `" s; s4 f9 {
.leds = da850_evm_tl_leds,
. o! M6 _ n+ \9 M+ F/ ~( p E$ M7 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( c0 x0 ]3 v- P) `0 \' A# H
};
$ x- f$ F# g/ a' e' z! l/ O! L5 I2 n+ ?8 [
static void led_dev_release(struct device *dev)
4 J& y" ]6 Z: E" n$ [$ O{
3 a1 D% M' V. h0 T};+ O# K1 g& u+ Q0 a
& i2 i- V( e* K( E6 Bstatic struct platform_device da850_evm_tl_leds_device = {
' B; V) M, T m4 Z- d .name = "leds-gpio",+ D- G0 X3 c$ h# n9 s* P
.id = 1,3 F: q% F; `3 Z' Q. M
.dev = { m2 C0 O/ j# S5 P
.platform_data = &da850_evm_tl_leds_pdata,
2 t! Q; ~( N M .release = led_dev_release,
$ X( @4 Q+ [7 ^! q9 z4 G }
6 u4 d M* B1 K. j$ y& i5 X};
8 f, u+ T- p! P1 H; T( M- ?- O7 K U p8 K7 z* m4 q
static int __init led_platform_init(void)$ N* P! }7 R8 d# m
{' ?2 x4 V; A! a- U
int ret;
3 @2 v2 _3 |( h3 K. P* P& y#if 0
8 U( _$ b% Y# s7 f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; N4 u1 _% X3 K3 f9 g
if (ret)
$ _% R7 M* K' F g7 D# B& h+ e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 i/ K" E0 I- Q1 p5 Q$ f "%d\n", ret);
t# Q7 L5 n0 a#endif
+ L. X7 r2 c7 m' c4 T% N ret = platform_device_register(&da850_evm_tl_leds_device);
7 H: g6 q! j) Q- Y. z if (ret)
t2 ^0 M/ ?" z, j7 z: Y pr_warning("Could not register som GPIO expander LEDS");
$ ^, m. q2 F! K. v1 ~+ h else
" t% F3 D1 }1 `9 |# s" J printk(KERN_INFO "LED register sucessful!\n");& x5 Z* \, a2 V. C& C
( @ f. w2 c7 @! |. n' A; A return ret;" o4 F# o7 ?% A" h1 ~4 b
}% p2 W6 c1 Z" U0 [5 S/ w- O( z9 Y
' C4 h Q0 O& a1 \' T5 Y& D1 b
static void __exit led_platform_exit(void)) i+ J: A4 \5 ]* m+ A
{
5 M' a: i, |; g) S4 D! _7 | platform_device_unregister(&da850_evm_tl_leds_device);
1 _$ h8 y9 u1 L$ w8 s8 Y% Z* P, O" e) w* Q2 d7 ~9 K
printk(KERN_INFO "LED unregister!\n");
0 T! s) k v2 j* ~4 b( j7 x}" H) Y8 G4 Z6 T8 f6 _7 g- L
; N0 Z- U" }: h4 c) t8 C, Qmodule_init(led_platform_init); }! B# {3 a' j; C8 {4 U) V+ P
module_exit(led_platform_exit);2 n1 N1 d$ m) L0 y8 d8 Y. P4 |) ]% q
( n" n+ |( j& o: @) T; VMODULE_DESCRIPTION("Led platform driver");$ `* y' X( a* {, w
MODULE_AUTHOR("Tronlong");
- ~/ u/ c1 b# F- y9 o; [MODULE_LICENSE("GPL");8 P1 r/ [) h6 d! ~$ s
1 \/ ]! k7 u+ L- A: p
|
|