|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" a" m! |, e( o
#include <linux/init.h>4 n5 O0 U6 r- C; U1 K' t* b
#include <linux/module.h>
! I M# i& k3 t4 N) \* F#include <linux/kernel.h>
* `' X0 L: P5 j3 D' b#include <linux/types.h>) D& q( ^9 z) x2 W2 j
#include <linux/gpio.h>
8 w. f7 y7 V5 E Q9 \#include <linux/leds.h>
0 H' N: d) O; D2 N: n# A2 }% f#include <linux/platform_device.h>6 i3 N1 x6 N7 L
3 u1 r h7 x( }9 a2 q, [
#include <asm/mach-types.h>
9 m* T6 V9 n- M) I! o$ z# F. p0 ^#include <asm/mach/arch.h>
/ _1 H7 i6 b; }$ L% N$ F9 d#include <mach/da8xx.h>- R3 m; G, X q: h/ b
#include <mach/mux.h>, d1 {9 w6 B O* Z
/ ]; m' [! f; ^8 B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
s7 g9 s8 b+ h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): D- L% E' c2 _9 ?1 X; A) \) i' d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: ^/ ]5 C; E8 s9 T) F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 t- s [5 V" o+ r
1 q4 M) O4 j5 V6 a7 a* G; B8 a( W3 y/* assign the tl som board LED-GPIOs*/( b* Y8 ]2 R. X5 J3 X! D
static const short da850_evm_tl_user_led_pins[] = {
7 C1 i8 @- Y7 Z1 |6 k/ } /* These pins are definition at <mach/mux.h> file */
& e! S2 Y5 ]! G( [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 P. x9 y0 T9 W1 Y5 C6 u8 s4 p8 G -1
" L( i! _# q2 j8 l6 h};. B# j2 I% h: l9 W: A3 s
9 ~% F+ ~( L2 G# k
static struct gpio_led da850_evm_tl_leds[] = {, p! i2 n6 T% M% r* [! t s2 w
{5 z, X4 ?. T# P+ C! V
.active_low = 0,# I q; a) d z( L6 D2 W2 K1 [1 c
.gpio = DA850_USER_LED0,
; _! G1 o4 U0 A% n2 E* V .name = "user_led0",. y+ n& k. n8 Z7 V X
.default_trigger = "default-on",
. q2 N2 V- D* J I/ ?/ L! J },
x! e n3 S2 {7 }5 d {& h! A* g7 l$ c- w5 ~) q' p8 Z1 O
.active_low = 0,
$ s9 @' {6 v6 C( x .gpio = DA850_USER_LED1,
7 [3 I4 v: O( T$ A* k .name = "user_led1",) D, u5 [" W# {4 R" f
.default_trigger = "default-on",8 o) S& d* c9 n2 `& ]$ C4 Q7 h
},7 Y* ~; j% {* Q$ x: G
{
' L9 u, u6 u0 h6 Z+ V' T .active_low = 0,+ ?3 _. B, E* n
.gpio = DA850_USER_LED2,# D. c$ L& r* h5 H! U% Q. O
.name = "user_led2",) ]+ `, T5 J/ U" D- p! U
.default_trigger = "default-on",: i9 F/ o: J8 R( e) k% L9 V
},/ a G& m! u7 T, N
{
- m3 u- H3 `9 K3 w" z1 b- S .active_low = 0,
7 e. R$ O6 s0 G9 Y .gpio = DA850_USER_LED3,
a( p2 M0 A! I! `9 Q& |+ D: C .name = "user_led3",
* B3 |& h) \; [* d% [! g |3 k .default_trigger = "default-on",
2 \4 H* L* B" @ }, K' V7 t1 H6 t- J- q
};
$ k5 }; H# B+ v+ s5 p; P0 Y; d; d5 W H# c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. |$ ~. n6 e3 U) q .leds = da850_evm_tl_leds,: q( T% Q5 I- e' [3 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ s3 Z5 l: b# b, w9 s+ X3 N};* f- t- Z( U/ R( a' g
* \, s8 Z1 } ^ S6 u
static void led_dev_release(struct device *dev)
, u( h- W% K! ~, [* F- m- Q0 v$ B. q{
0 e! q% R/ W: |; K% {};7 m2 W' u5 X( j4 s5 E
4 b+ m& S2 E. z8 }: e8 s T
static struct platform_device da850_evm_tl_leds_device = {& w! z% A2 [$ \( ]6 ]0 {7 F0 [ B
.name = "leds-gpio",
; K) N5 G/ c/ e3 o) O4 I .id = 1,. {. J0 t4 d5 ]! A- j" O; D1 r
.dev = {
/ `; ^& s5 N9 X2 ^/ h9 @" d .platform_data = &da850_evm_tl_leds_pdata,
U, G# J6 q' V% U9 O; k .release = led_dev_release,
0 n8 F6 L# K9 Q% l# M, j8 ^ }! H. D$ F6 l/ ^8 F( u
};9 N0 c6 e0 {4 O. C& C( L/ [
; Q: Y5 g3 g. D( ]5 M/ Tstatic int __init led_platform_init(void), c# V5 [7 l0 V9 D7 Z
{0 o! G" L+ z7 B. y/ t6 n8 M7 e
int ret;# Q# w7 I% z* R5 z% R' E1 V2 A
#if 0
- C9 I# Y! T0 t1 ^2 n0 t7 B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); p) X1 n2 r. U0 I5 g+ P) Y7 g$ w7 Z
if (ret), c& p/ q3 V0 S+ m' d) v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' G2 L5 a1 O6 z- \
"%d\n", ret);) W, ] j- r7 L, ?7 A3 e' b- W; W7 N
#endif5 V/ K4 x- ~3 C
ret = platform_device_register(&da850_evm_tl_leds_device);
7 h! s# a& b* C7 T, w if (ret)
+ B4 n) v. D. J! x+ ~9 K pr_warning("Could not register som GPIO expander LEDS");+ d3 r8 W& C$ b/ s1 x
else) M$ z8 t' k: A3 T* \1 D/ Q+ }. a
printk(KERN_INFO "LED register sucessful!\n");
- x3 V- g' z0 N0 y6 E) o
5 Q5 o0 O9 S% Q# @5 I return ret;
Q% y' U* A! L- F6 E5 }8 T}
3 k. X7 ^0 G6 x$ @: F) S
$ a0 X. L- t0 a/ `2 h1 t% h3 l% ?static void __exit led_platform_exit(void)
3 R# W% J9 ~. Q6 I; V{# k+ u+ J* T6 p" m
platform_device_unregister(&da850_evm_tl_leds_device);9 t1 F9 x' ~; u* q( m0 N
+ k4 J2 ^6 n# g4 c
printk(KERN_INFO "LED unregister!\n");
- a, m6 d0 v0 p+ L. O, A}
! H9 U3 m' J8 o
+ q: o+ e1 T+ T0 W2 V" pmodule_init(led_platform_init);
. I( T" j9 C/ l. Pmodule_exit(led_platform_exit);, ^& S* ?3 |) v) F8 F
0 r+ T0 y5 _1 p. r3 K
MODULE_DESCRIPTION("Led platform driver");
7 [- y/ D' e" J" wMODULE_AUTHOR("Tronlong");3 X/ U( o; L3 I* c9 I; i
MODULE_LICENSE("GPL");
) ~3 U- J1 G" r' X& M+ ?# w$ e) ?; A0 @) F, v. r$ k
|
|