|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ M2 S) _# }. n
#include <linux/init.h>
0 J+ [1 d# _; J8 e#include <linux/module.h>% u) }, [" `9 x5 H D1 x; k) b2 s
#include <linux/kernel.h>7 F8 g: `! U: q5 U9 g7 }
#include <linux/types.h>
; l& d* \* S3 M' ~#include <linux/gpio.h>
; e2 h' A' n8 ~+ F( E7 S$ w#include <linux/leds.h>
: E8 q% l: f, f/ F5 h#include <linux/platform_device.h>' t$ s* B8 H2 u
3 H- Z7 C3 ?2 m0 W- G- I1 i9 T4 h/ Q#include <asm/mach-types.h>6 C5 `6 e1 o: I. E8 i3 p c
#include <asm/mach/arch.h>, M N4 h$ s" ]3 b4 E; i* d
#include <mach/da8xx.h>
/ G, E4 R( u8 h9 {#include <mach/mux.h>
; V( F) T6 B1 @7 N% Y7 v2 f/ ]- K$ `+ X! O# L; y) H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( ~* v7 T; x* v/ z7 t, J( t H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 t' T4 N$ B T% [$ x( _, O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ ]. B) k- m% i: d- ]& M# W. S% y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), w6 u U! d. [$ k/ T2 i/ R
8 E, ? S" `1 l/* assign the tl som board LED-GPIOs*/5 D: F' {4 c( N, A0 {% b. ^
static const short da850_evm_tl_user_led_pins[] = {+ u# `! b7 b' |3 U& @. c6 S
/* These pins are definition at <mach/mux.h> file */
' B7 R2 e* q* z1 g5 w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ A7 ]% t/ R: d& L4 m. _, |! w" u
-1
# t# G- }8 f! F) c; c/ N};# O7 A. Z2 w4 U
9 G5 U6 t# T) y8 K. qstatic struct gpio_led da850_evm_tl_leds[] = {
* H* E Z" s8 Z) Y' ~ {& |. q5 R! i4 n$ F: u2 [2 o9 Y
.active_low = 0,; v4 X% O" f8 g/ V
.gpio = DA850_USER_LED0,, A1 I U+ n& U" e( I$ h4 b
.name = "user_led0",
' [% ~, ?$ H" ^ .default_trigger = "default-on",; C1 g* u! A; `' h
},) L$ Z$ W. J/ S0 D3 D
{
7 o$ g" K8 f) t4 }8 D .active_low = 0, x- ]' U' c( V5 Z4 ~) z
.gpio = DA850_USER_LED1,/ ~7 |- l* Y% B' w5 S
.name = "user_led1",+ h/ m9 f$ ~1 N7 {+ U
.default_trigger = "default-on",9 X2 u+ s& ?3 z! w
},
. Q( s# E, F2 C% M( Z, o# w {
# t1 J5 T* k/ _+ v2 a .active_low = 0,
- Q% h$ ~# `; R8 y5 j .gpio = DA850_USER_LED2,
+ Z) t5 ]: x# m .name = "user_led2",$ U1 I& }% l6 ]) j
.default_trigger = "default-on",+ \! G" F, i! w4 A
},
6 c J9 R9 q9 ]' j: e {
$ d) l2 \" h; L! e- I$ r .active_low = 0,% S% A+ l3 f$ [% [: P& m
.gpio = DA850_USER_LED3,
0 ?, V8 C! T* d! T+ f .name = "user_led3",
8 P: U* F j* O5 n5 Z4 ^ .default_trigger = "default-on",, ]$ z6 n$ A; x! ?! ?: T+ x s
},, n1 ~1 D5 g4 r9 E; V+ O$ ?4 w
};
8 g ~; I; b! `# ~9 H. L: e2 Z$ z, }' r' \/ f; H1 {3 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& x1 P! ?+ A/ |% h) G7 H
.leds = da850_evm_tl_leds,+ c r2 \1 X3 C, n9 ]3 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," D* P; x' [1 D, |
};6 E+ T6 ?4 p& U$ z: R1 r
% {. b3 h$ [$ w6 W9 h0 P, Z) @; Mstatic void led_dev_release(struct device *dev)
- \8 I; Q+ Q1 w) d- Z) c8 l0 Z{, W0 M; `1 f& T' z% V2 _
};
: x( O" e4 j% x& P* H4 W' @* u4 G6 E8 A2 U' E6 ^" B
static struct platform_device da850_evm_tl_leds_device = {" r" C. t+ ~2 F9 j
.name = "leds-gpio",
* Q3 j0 P3 w3 P0 g: i$ B .id = 1,
( u& {+ M/ T! n* x- R& f" W, H .dev = {
2 Y, U: w8 ^- P4 ~, H .platform_data = &da850_evm_tl_leds_pdata,: {6 c8 w0 A' _3 {& D
.release = led_dev_release,
/ K4 a; X J1 V( Z }" ?1 G3 U3 H2 C" c2 z
};
?3 N) p( L: i5 Z8 J8 s3 A" G. s" ~/ V. M
static int __init led_platform_init(void)
! ^$ b6 Y' s- N' ?1 f' z4 t{
+ I0 `1 A. F+ ^* w+ q; D3 d- r; G int ret;1 s- k, ]7 o6 B: l8 x* S
#if 0
& |' h) y+ v" w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- H% g" i W8 N' t/ S
if (ret)
# t/ M: b k$ I( L' s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& c6 a) z4 M$ N# C3 N4 a/ Z
"%d\n", ret);
6 L7 t( ]' B; U7 a#endif
4 N; ]( x8 @ y4 ?1 i# P8 {. s5 h ret = platform_device_register(&da850_evm_tl_leds_device);0 | g3 |; v; X' C: K; |
if (ret)3 [) N1 R: Q( B; ]. t! x
pr_warning("Could not register som GPIO expander LEDS");
! f: k: I! o: L else- n$ K A6 w9 A+ r# r4 V. j( U# @
printk(KERN_INFO "LED register sucessful!\n");/ K1 f1 t. M% @& P# B3 A& C
k/ L1 Z9 n: f- a8 f return ret;1 R) R* B9 \; {- |9 j. ^
}2 d$ [2 \+ M- h: R& w
; g# y7 G! b9 P5 A
static void __exit led_platform_exit(void)
; T, ^" w3 l- Z7 S: J5 `8 W{
: R, |9 ~* s" R8 L1 Y# i& C0 Y platform_device_unregister(&da850_evm_tl_leds_device);
6 Q" T( G5 P1 Y# K" w! o' }) ^% f8 b8 H
printk(KERN_INFO "LED unregister!\n");& b$ h( A- a% ^& {
}
. s& o& i" Z7 a* x5 C: S3 ~8 |' u' w9 X$ U+ x' J' m
module_init(led_platform_init);, A2 [3 \/ w4 W2 O: H- _) c
module_exit(led_platform_exit);
) A2 g6 k# g! m" ]( P
% ?4 F! r1 V$ PMODULE_DESCRIPTION("Led platform driver");
1 ~4 v Z! X% D" g& BMODULE_AUTHOR("Tronlong");( `9 {2 _6 U& E$ q! b# V! a$ |
MODULE_LICENSE("GPL");1 N* c% k2 _6 V
4 T; K) G' m( u% F: _3 f9 g9 u |
|