|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# C, B4 M, O! j6 H
#include <linux/init.h>" S0 ?! |' |# m: h
#include <linux/module.h>
T7 `8 F1 p: j+ }% O% {6 ?#include <linux/kernel.h>1 I% C* u! V" s
#include <linux/types.h>
- m3 K" k/ w' ]& Y' v/ Q' E- T8 M#include <linux/gpio.h>1 o5 Q5 r* s( C0 h' |( Q: ]1 p( ?
#include <linux/leds.h>
4 L& D/ O* o( H# }# u#include <linux/platform_device.h>
( z2 Z7 z# s' l
# D/ h+ e1 ]' I; I( P8 G" K#include <asm/mach-types.h>: q! C) }+ w& \( ^7 N& {1 K$ G' A
#include <asm/mach/arch.h>* ~! F8 B* _4 O0 {# m
#include <mach/da8xx.h>
+ d! P& ~$ u6 F2 j* L#include <mach/mux.h>
) z- w; v- P8 r- R- V, l
7 L' v6 _" }# |* K5 H5 P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- |( V- N8 ~& x8 D2 d4 x* ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). v+ q7 C8 P; H( o- O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( F F" F" G3 s7 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 ?, D2 |* o, u4 @. z; K! {
. n* R- R$ P% J7 I9 X7 e1 _/* assign the tl som board LED-GPIOs*/
) Y. W' E2 u* A1 R6 kstatic const short da850_evm_tl_user_led_pins[] = {
( o7 S, L8 L" k2 a /* These pins are definition at <mach/mux.h> file */
1 a5 `7 X6 M2 q: L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 Z- L0 e0 q$ g
-1
0 R( U/ O; B" B5 V1 f$ |};& L# V% w t& s0 @
V6 e3 t# s: ~$ U* `static struct gpio_led da850_evm_tl_leds[] = {
6 }) a, x$ P0 r {
/ q# E9 M' M! K. f .active_low = 0,0 _' P: D5 v/ q" @, F+ ^8 x0 v' q: E5 _
.gpio = DA850_USER_LED0,3 _( Y0 {5 W. n) b4 Y
.name = "user_led0",5 n) t1 |, Q( E9 A' B
.default_trigger = "default-on",
1 U8 k& B" `, l% d },
: f/ b! J( C& y; X {
5 Y5 T& q0 O3 k* m9 d& }6 k& `7 N .active_low = 0,
# F6 N3 a2 n$ o8 ^ .gpio = DA850_USER_LED1,7 h/ P! K( O& T/ ?& O2 ]
.name = "user_led1",
" e1 Z% _# s; r# H- D6 N .default_trigger = "default-on",
$ k3 c2 @3 \! t$ L- O5 |5 v. R },2 ~+ b( k5 g0 P' n" w) a# v
{ _* B) Q, h4 L8 ^. b; ]
.active_low = 0,5 }0 P. U/ @' a0 r7 S" s5 D
.gpio = DA850_USER_LED2,# Y3 {( V; p$ `! G; W" g- c) _
.name = "user_led2",
! K, ~8 Z$ V5 L3 I .default_trigger = "default-on",& h0 Q" c" H3 K/ r) P# g
},2 S; _& P& `7 z! U( S
{8 f9 J/ m; V3 y% B- u* K1 n Y6 I
.active_low = 0,- R- j# q; o5 u1 x7 c2 D2 l
.gpio = DA850_USER_LED3,
' E% S4 K$ u; p: | .name = "user_led3",4 i* x& v# T0 G2 r
.default_trigger = "default-on",1 l2 J' _/ h% I, B6 n
},: ~: P; p6 I, d5 ~: b1 l, x
};
1 L% D+ r8 P" a# S5 }( A
2 y+ O1 J9 o! I: D* g& Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; F0 g/ Z, o) n: e! a9 }$ D* j
.leds = da850_evm_tl_leds,2 ]1 H1 U; J. ?$ X7 H( ]( I# m7 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" a+ A7 }# _, v6 A9 `0 J};
! i- C% [/ @) F7 m# \9 p& s0 R1 \0 h3 T$ a& I: A
static void led_dev_release(struct device *dev)3 u3 X2 o" i% f5 O- C
{3 q1 o5 w2 p8 o" R: C" g$ t4 Y
};
& s3 K r/ D# ]' J, {
3 M& w2 W( J9 W3 {: U5 K8 L1 zstatic struct platform_device da850_evm_tl_leds_device = {( @% e5 n6 y) m% U0 e& e9 m4 n
.name = "leds-gpio",! I3 Q- P! A1 g7 r' f4 y. R6 k
.id = 1,7 x& Z _2 `3 l
.dev = {
. ?$ @( l8 O5 M5 W5 v X .platform_data = &da850_evm_tl_leds_pdata,
" v/ G" e! @% X" l .release = led_dev_release,
; i; o" b K& ^$ v6 E& B3 ~) |* R }
: a* N, D, M* Q};
8 K/ ]5 _; h6 M" T5 E3 V+ L' V7 o' M3 t/ H7 }! a2 k3 z: Y y
static int __init led_platform_init(void)
# M1 d6 H* S' Z1 f{
$ N7 x2 S3 e0 H( C* \) q1 r int ret;
" H q& n8 _- z1 x+ e#if 0
. k2 h0 S; ]* G2 G, \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: Z; W: ^# ]. R6 U+ T v( f7 L
if (ret)" B& |4 X0 L) U& }* Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 M* j) _! q2 Z: R* M' s$ g
"%d\n", ret);, j4 S- q2 D# s8 q% [- b2 n
#endif' U6 A; R% }6 p) Y1 u. @5 W
ret = platform_device_register(&da850_evm_tl_leds_device);
) y" r6 j5 f6 G9 r& t' M5 P' Q, G if (ret) {1 [$ D+ }( n/ l6 A
pr_warning("Could not register som GPIO expander LEDS");. d' R& D' a% H0 k7 F
else7 A9 J& S% a# d/ b) U
printk(KERN_INFO "LED register sucessful!\n");( Q1 ? b6 [' B0 X* J
& c5 z: k5 }( F- A ]+ ^3 ~ return ret;) F* e) ?, W' a
}
, E1 ^0 {( t( H" T1 k( l
w% w- k( Z! \* e1 qstatic void __exit led_platform_exit(void)
L4 |& M( V: r1 R3 H' F* P{
' g# U w. c. d4 E+ m" |# G platform_device_unregister(&da850_evm_tl_leds_device);
5 W2 B. C% S& {3 M0 K: M# L/ |5 k$ R: D: @" j
printk(KERN_INFO "LED unregister!\n");2 c, x, Q; Q. m6 X0 E2 ?3 G
}% {& Y7 x8 ?" J/ h& j; Q
/ r* x; u( I" K/ ` f8 Tmodule_init(led_platform_init);
. F$ v4 f( E# v$ W; j5 Emodule_exit(led_platform_exit);
; `9 I$ f t7 C6 v s. c
! u% c! n2 d+ ]. L8 i @' f( P/ M! bMODULE_DESCRIPTION("Led platform driver");% z j0 g- R/ z# U, w* @, ?6 V
MODULE_AUTHOR("Tronlong");. S' I$ x- I5 g0 E0 C
MODULE_LICENSE("GPL");
6 q Y+ n* o2 J/ ~0 V7 P) ^
# O$ t& X# X' ], K2 D4 A6 W9 J- R5 Y |
|