|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 W, H) D3 q8 f/ c
#include <linux/init.h>
! W1 @, |% U4 F#include <linux/module.h>
; V# V1 J( @' K+ h4 H#include <linux/kernel.h>
. r C5 b" N, W- I#include <linux/types.h>2 O1 n. v j' Q
#include <linux/gpio.h>! J: W) |! M) Y$ k# `" K* t4 w
#include <linux/leds.h>0 Q. H# M5 c1 C6 N6 w
#include <linux/platform_device.h>
+ P4 ~/ z3 L( A) l) m# f( t( |7 j+ ^# U6 ^. z) v: ]
#include <asm/mach-types.h>4 g' d9 {. o) {: n* E
#include <asm/mach/arch.h>
6 y# s% w7 m( K) f# z L: J#include <mach/da8xx.h>" g* O% {3 g, J* x! m* ~. w2 ?
#include <mach/mux.h>
7 M' d% W( [% O- i/ K+ ^# W+ j0 G' k7 U$ s* Q4 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' q. T2 r" @0 F0 W7 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) u# N2 F' Y1 g$ z5 P) q, o* Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- n+ w2 G, N/ Z- ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' N8 L+ J$ _: |7 N, j. c/ t
( K' {% V, U+ P3 m8 v
/* assign the tl som board LED-GPIOs*/9 f' e# Z( |( p( |
static const short da850_evm_tl_user_led_pins[] = {
+ w/ i! r; A/ l. D- }4 t /* These pins are definition at <mach/mux.h> file */
7 ^4 T1 f% H2 ?, c/ t+ M/ I2 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 T7 z. E. b/ b" s
-18 k0 }2 f" y. F- [8 t- C% \6 m
};. Q9 M9 M. N* ~2 X, U* w
& Z. J% v1 t' z6 E- L2 Q4 tstatic struct gpio_led da850_evm_tl_leds[] = {
; n1 V8 e) N. } {. f( F# l1 l1 R8 c& E0 l
.active_low = 0,
* q; ~2 `8 F7 |- |% j* a1 I! d! E .gpio = DA850_USER_LED0,; \. q4 N4 l$ D: r5 k/ Q2 z
.name = "user_led0",
0 v2 d( W% W# S2 e .default_trigger = "default-on",, F% K! v2 x9 q, C
},8 |0 A3 p1 n8 d/ f0 b# i
{6 R6 K7 ]) P4 ?3 {9 N# N- c+ C
.active_low = 0,
, _, A/ J5 o7 o# r* V: [. f .gpio = DA850_USER_LED1,
+ f& n2 t- i( G( n8 W .name = "user_led1",! m/ E( H0 n) F. |- G n
.default_trigger = "default-on",
) F2 ]$ N* i! P7 F7 S# V& s5 D# v },1 r6 j, ?' L- k- Z5 T2 u6 N
{
* `+ l$ ^' Z3 o- A/ b# D .active_low = 0,( D0 a; s. a3 @3 E
.gpio = DA850_USER_LED2,
3 [' j) V6 ~% H% a0 u# j% G .name = "user_led2",5 b ?# o+ g' q" W$ a: m4 T
.default_trigger = "default-on",* D& d2 ]8 F. T$ w
}, x" P; r( x; ~# t6 A. g
{
: C0 a/ s$ s, O& _5 J4 } .active_low = 0,+ s9 f+ I& i2 E ^" h. X3 A
.gpio = DA850_USER_LED3,
5 I; `0 c& f- j6 S4 h .name = "user_led3", c5 N/ z$ H0 e5 S. ]; m, V. p
.default_trigger = "default-on",
! f! D5 G3 U7 u0 |& O) K },% y% L+ i6 N1 U; i5 |
};
# F4 @/ Q4 {& z' v/ \2 B( S3 W. m& ~; K1 O @$ ` }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! ]/ i* K7 ^' m4 X, T, s) X8 I .leds = da850_evm_tl_leds,; P. E% H/ \/ p% U' @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ c* K, l# U+ q& P};
0 n' L# F: I, |# \* Q
7 W) s# ~, c2 ]static void led_dev_release(struct device *dev)
2 H2 G, ^- L+ \ ]- n{3 U8 Y' w( `# p! H1 b* e: u: _
};& Y/ N- X7 e3 v& x, K5 C
; h) F2 @0 t" {0 I/ Y
static struct platform_device da850_evm_tl_leds_device = {
* H/ F: @8 i$ z" s( z' a- _# g5 s .name = "leds-gpio",
5 o+ z0 M: N5 W* f$ l2 ~3 G9 Q .id = 1, @+ [4 Y' x( r8 L
.dev = {
$ d: T. u7 d% t% d: r+ @* g" q( v .platform_data = &da850_evm_tl_leds_pdata,
`/ A+ i) @6 `* t+ b .release = led_dev_release,
) }4 [5 `" A; A2 _6 [) B }
' x( |' U! z7 @+ d! X. M, k};
+ `7 [# p9 L0 z
) E& A3 u2 I! L$ P* A( c4 ?static int __init led_platform_init(void)$ r- r; \( ]; | e+ l2 \& V
{
/ V& n+ m4 l$ Q9 j; p int ret;( j9 |/ q! R0 z( ~) |; ^1 p
#if 0
6 I2 [' w1 r) A7 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 y3 j; e3 ^3 K6 r; B' N9 Z8 H if (ret)- K+ ]2 @5 H+ \6 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! w7 T* K# ]5 \- D, |
"%d\n", ret);
& ^& f O' w# l#endif
% q7 l& C+ K. g" R+ ~2 V: j, J ret = platform_device_register(&da850_evm_tl_leds_device);
- k) b5 }/ N; x0 K ]) Z4 q- a if (ret)* H' e/ n/ Q+ o1 w' {
pr_warning("Could not register som GPIO expander LEDS");/ n; A9 l; e C' U# J5 h& @
else0 h" ~; r' Q# `/ e9 R
printk(KERN_INFO "LED register sucessful!\n");
5 }1 D( |. j3 z$ I6 Z- c9 @6 t
: z6 D$ s' W! D) `5 v# O return ret;. {5 y2 F* l, t( v
}9 V, V% _* l2 _7 u6 |: {- ?" C
1 l& N" z6 x9 V) K! d8 L6 u" Tstatic void __exit led_platform_exit(void)
" q0 e3 S5 D" q" b0 {7 P X{
7 N# t" A# F& j& d platform_device_unregister(&da850_evm_tl_leds_device);
8 u w, ~1 u5 @6 F4 C, ~2 n* G N8 o a2 G
printk(KERN_INFO "LED unregister!\n");( o; g* h4 h' j) ^% [
}' ?9 K1 i2 i6 j$ p
0 }# l% l3 ^ D, E
module_init(led_platform_init);
' y1 V2 }( ]0 c6 Dmodule_exit(led_platform_exit);
5 |$ b& w1 B/ E+ [; \8 ~5 ~ ^- u" _2 z, E
MODULE_DESCRIPTION("Led platform driver");
7 S/ H0 m: Z2 ~2 jMODULE_AUTHOR("Tronlong");! I7 y& z; e- I2 \+ R) c
MODULE_LICENSE("GPL");
5 L( P6 f$ C* }: V F; p4 ]6 a" n+ H" c) B
|
|