|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' L7 q6 _" J; _
#include <linux/init.h>$ `! P5 n. n. u8 n
#include <linux/module.h>0 n$ q+ e. ?; S9 |8 i- B
#include <linux/kernel.h>: N" A. m) H5 c. T3 g. D: n
#include <linux/types.h>
. X, A. f& |; M+ z: b1 C#include <linux/gpio.h>5 _9 C, F8 D1 ~, [ a5 y8 p- h
#include <linux/leds.h>; Q3 t2 o0 ~% E8 _+ u- G
#include <linux/platform_device.h>
6 M( v. k' w/ ~( c
$ W# B6 [* y+ h1 G! G& |#include <asm/mach-types.h>
/ R( R! p( \/ ^' r' h/ P! n#include <asm/mach/arch.h>' I G3 `/ Z. z" d/ K% G0 x
#include <mach/da8xx.h>% Y# T5 }( G6 t. X& F1 ]2 q3 H
#include <mach/mux.h>% l7 v% }% n$ E) C, S
4 t1 g, k; @6 {5 e1 S3 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, W- ]0 }+ v# [* t' ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 i0 O' A5 Q* p% F, w2 A8 R8 o, y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' [5 @% C7 Y$ a0 d' O; E8 J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 M* }% S' w) |. v
* v: o' G1 R4 ]+ O
/* assign the tl som board LED-GPIOs*/
% ^& j6 f( [. j ~9 hstatic const short da850_evm_tl_user_led_pins[] = {
3 _) x9 e5 `$ E) ? /* These pins are definition at <mach/mux.h> file */ D: p2 p& C$ |! @; S/ N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 G4 B& h" q% i5 `: m; K -1
% }% F; V& D* W};5 ?6 Q, ^% X3 g2 O$ G0 n1 Y
: T, E+ b9 I3 ^9 E0 C6 u
static struct gpio_led da850_evm_tl_leds[] = {" ]9 Z4 e) q* C; ^; Q$ S
{
' E! |3 {+ Q$ O .active_low = 0,
+ X/ S/ h4 j7 y) t2 s2 }9 `0 T- K2 O: W .gpio = DA850_USER_LED0,/ [/ g& b7 C6 @$ n: Z8 G1 Z. r
.name = "user_led0",
1 o% f: a. i' Z' l6 X .default_trigger = "default-on",$ p+ _- o9 o) x2 s! D5 m6 z
},
4 ]+ K0 m8 N9 R& Q3 k$ n. u {
" k4 K: \$ a' X; P- Y% _! O .active_low = 0,
4 @) O4 _9 t$ b0 R( y2 M9 m* M) q .gpio = DA850_USER_LED1,
8 k6 f# O! q4 n .name = "user_led1",1 l" Q, U; D, ^: v O8 k' U
.default_trigger = "default-on",
5 b# P' c8 C( |4 `& N" g },; O: z6 ]0 u" ~) F) ]4 c
{5 n" @/ ?$ g! a$ d
.active_low = 0, X* I7 A/ a9 K2 d% A: E5 ~) }
.gpio = DA850_USER_LED2,
, D: ]+ p K; c% L. Q .name = "user_led2", e3 B( S7 N9 b, g/ r' F( `
.default_trigger = "default-on",% |) R; X0 N& P
},; n9 S( c$ g+ x) ^' ?$ n
{
0 {7 ?% k: t- B S9 F. N .active_low = 0,
0 J ?* k7 ?! G0 |- A .gpio = DA850_USER_LED3,
, @0 ^0 D; m1 _3 R# \5 s0 u .name = "user_led3",; A6 L. n- Q" W0 Y
.default_trigger = "default-on",
7 g# x$ k3 f, ~+ [( T- Q },: A2 n; I2 U2 h
};8 {8 |, n( p" V2 a/ H& J* O) I
( O" E+ k* v1 h) `4 \4 e2 A$ s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 _9 h" e' V9 i( H5 P) a- P6 ]
.leds = da850_evm_tl_leds,) G9 V/ t, A. _8 }; y5 }+ _2 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( W9 [& z& p1 G1 j
};% w3 R$ r: h: A7 ?4 z! g, j( J( e
; B- R) Z7 W0 x, j( m3 s: R$ ]! cstatic void led_dev_release(struct device *dev)5 N$ e2 @+ T, |' j' J- b6 U
{
3 d9 ^# `3 ], b3 o. y};
# s- t5 t7 B6 c9 H
: X) g- |/ ?: l4 ^5 ^static struct platform_device da850_evm_tl_leds_device = {3 p2 _- v- h. c" {5 }' J7 j
.name = "leds-gpio",
) O& p' t' s2 Y, f, s .id = 1,
$ u/ X8 Q4 B1 m) Q0 S2 d+ Q9 @; m7 d .dev = {
* [4 k- N& v! A$ f. J .platform_data = &da850_evm_tl_leds_pdata,( W& f/ y. v0 R: P1 |+ `/ k+ s
.release = led_dev_release,
. b. I7 O, F) z8 k% J/ P }
6 I- Z' C# e1 h1 P};
& @* k% {' i; ?! `" g [% D) Z3 p4 l- {0 w
static int __init led_platform_init(void)
% {/ W% Y9 v& D; }0 G) D) w; i5 y9 K9 |{9 z; K# h. `0 }6 k5 R/ C; x% m
int ret;
4 y- P' X1 S. r# D" s) }4 Q#if 0/ T4 Y! t0 B5 ^: w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! c9 z9 Q2 w9 y5 l3 t$ g, |$ w: Q% ^ if (ret)
7 V( C% d# R9 q u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 k, B8 i1 z5 n; e c
"%d\n", ret);, a I9 p" E( n, W; y% q
#endif
7 b5 D+ B O- @6 F/ C0 c5 ~ ret = platform_device_register(&da850_evm_tl_leds_device);
# ^7 G% F2 Q4 z$ E' r6 v if (ret)' t6 y! [$ q- L
pr_warning("Could not register som GPIO expander LEDS");
7 @2 [2 p4 E# l else. x; r+ T7 V6 K
printk(KERN_INFO "LED register sucessful!\n");) d& `( _8 H3 Y- Y3 ?+ _
' [. H" J* Y$ C3 O
return ret;
J5 C8 p8 P( a! g# g8 Z}+ w6 W7 b; @2 h4 p9 X
6 N2 F/ o# ~# t ]2 m( bstatic void __exit led_platform_exit(void)
( H" \6 P- C+ r" [{" e% e6 v! L2 U) `* e% I( ]
platform_device_unregister(&da850_evm_tl_leds_device);: Z8 f3 J% T9 S
& G9 f" M) t# Q; y- b5 H& n* L
printk(KERN_INFO "LED unregister!\n");
5 A3 X0 a2 H9 h}0 X; d2 N' P' `" o( V+ h
; T4 f- c6 _( u! b# B8 R& s
module_init(led_platform_init);
( t" u3 U. B9 K1 ^9 zmodule_exit(led_platform_exit);7 q8 Z+ v5 ^8 w
/ a: k- V4 i. [# g* V
MODULE_DESCRIPTION("Led platform driver");3 q1 r/ t& E4 Z, G- D# {" \
MODULE_AUTHOR("Tronlong");( J; J4 ^7 q s' P6 m1 j' H6 y: N* G
MODULE_LICENSE("GPL");. y; H+ C9 Q9 W
: o; P3 L; M" {) C& j0 O
|
|