|
求大神给下面的程序做注解,请稍详细些,谢谢。) Z, y' w: r0 Y% {2 u) J+ X
#include <linux/init.h>
! D% S5 q0 M( _/ |#include <linux/module.h>
0 { ~* }. K- J- N8 @- h4 ^; y#include <linux/kernel.h>. A* S& H7 W; o( [6 L% q
#include <linux/types.h>
. \: X2 p% y$ a e% \1 n#include <linux/gpio.h>
; O% \: G% o7 m& Q. Y G#include <linux/leds.h>
& `6 Z* w7 f' x2 P#include <linux/platform_device.h>
% p2 e& h8 B$ x1 u0 G4 K/ P" s. y$ \4 I& F
#include <asm/mach-types.h>
' D- ?/ ~+ H: [& K/ ^7 n$ N3 [; n#include <asm/mach/arch.h>% t8 Y& V A# U% d0 `, h
#include <mach/da8xx.h>
7 e! ]* P- r0 ]5 L! F' q6 G#include <mach/mux.h>0 ~! X) `( d" W' }! _
2 V* r1 l' e+ a9 N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; G0 @8 T+ c! d- w0 N% w- }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ |) Q7 `* y0 _2 L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" v, o: X% L% ]( a) M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ n1 N6 E8 R% d$ U& \5 x" G: r" C" a- a5 u8 p' ~: j
/* assign the tl som board LED-GPIOs*// R! `) X; X0 k v- d
static const short da850_evm_tl_user_led_pins[] = {8 m6 w! J, N2 U- W" `: c# q
/* These pins are definition at <mach/mux.h> file */
w+ e( g) j9 b/ j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 X# z, p. m# F% c- ]2 a3 P -1. [2 R) f: i+ X1 m8 v
};
2 c' Z1 Q/ F6 `" L; X6 a* I9 H# F% O& O4 j0 ~
static struct gpio_led da850_evm_tl_leds[] = {! H- I) G# e1 z: F7 S
{
' @3 E) {/ g9 ?7 x2 g" I6 } .active_low = 0,# K5 N4 P Z" F0 K f
.gpio = DA850_USER_LED0,
% N& _9 g7 g$ ^' J/ W .name = "user_led0",, I8 a. E8 r$ E1 h7 w
.default_trigger = "default-on",
0 `9 w# X# H5 H0 Y1 |0 q5 X) U },6 h% [* |5 j& h2 D: w) l: x
{ d/ D/ g1 d. Q8 V- h
.active_low = 0,
4 x2 W# W) ~) _% G7 `5 q/ @% n& X .gpio = DA850_USER_LED1,9 [4 s0 X( M* p e& o
.name = "user_led1",
6 {, s3 H7 U, N! I' a1 R .default_trigger = "default-on",. q2 }+ u. P9 `+ c: m7 n
},
6 N7 C4 a+ U; D8 v7 i {
" R3 q$ d/ f8 @3 O4 T' c O .active_low = 0,
2 z* F$ M6 v+ R- ?" n( T: N0 y .gpio = DA850_USER_LED2,
8 b! ?0 u2 h/ R& v .name = "user_led2",- w5 x) ^, C7 }1 h) z
.default_trigger = "default-on",; D$ @0 A, s' `+ W9 r7 V! I
},
8 ~4 `: H1 t8 B {1 K Y! L* O$ H1 d
.active_low = 0,1 l7 K9 l) e9 X/ S) F3 x
.gpio = DA850_USER_LED3,
3 C: N. _5 z! c; q .name = "user_led3",- S& O+ O: O# R$ m' M+ M- ?( G
.default_trigger = "default-on",
+ d* Y5 { Q6 }& _ },
) z; `9 }6 x' S1 C, T: a; i) ^1 U};
9 y9 h! r7 Y5 y3 U$ \+ P( ^5 u$ X/ l1 U. N, N" g5 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 F1 r! |/ F5 b8 T: U" Z2 `, [5 k .leds = da850_evm_tl_leds,' H: a) x8 D0 g9 O% T6 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: Z+ g( ?; R( B( h" h};* @0 Z8 N, j! `- w
6 n3 l, F* ?; k8 Z
static void led_dev_release(struct device *dev)* |8 u B2 m+ ~/ B1 Q `
{# ^( w3 s6 Y6 b/ x' ^# G) E m
};
' ?( q8 A: ^) L q7 j1 H) m; q- y3 S4 Y0 J' \: T0 q' {9 Y C
static struct platform_device da850_evm_tl_leds_device = {: q! M5 l) o8 S$ W
.name = "leds-gpio",
8 g' v7 g- u0 x& k/ m! T" C4 r' N .id = 1,, ?( \: z% S8 m( g2 }
.dev = {
) j8 l* @! Z5 h* A# ^ .platform_data = &da850_evm_tl_leds_pdata,
. J& P1 l7 R4 n1 z& y( l0 Z1 b .release = led_dev_release,( v L# v Q+ ^
}$ m) O, t8 P* i: G' }- q
};- C7 ?7 d" m& {" D n- |
: q4 }/ _/ ]% P- e( o$ K$ m9 x$ astatic int __init led_platform_init(void)
: V" M2 u/ f! r{# S) O3 u$ ]( y- a1 `
int ret;
; ?* x2 ^! f- b#if 0
* I6 X$ W/ u5 X. {! p. s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. q. G: V; |# @; x8 b+ }6 i
if (ret)) T7 s6 P, ]2 H% x1 S/ y- Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 L9 t# J G. T* b& j) H* D "%d\n", ret);
+ O! u0 D7 @+ H2 I3 A#endif3 C3 ^+ s/ b6 j" K' ?
ret = platform_device_register(&da850_evm_tl_leds_device);0 M5 s2 \8 `/ e! u5 r; x% j4 g! S- ^
if (ret)
6 E0 Z8 A' }" W2 z2 y$ y pr_warning("Could not register som GPIO expander LEDS");
( h* f: y& O" l5 j7 S% Z else3 ?! f# q, A8 `
printk(KERN_INFO "LED register sucessful!\n");
! g3 @9 N- N0 _
; }& t3 z0 H9 W2 c return ret;$ {- c1 c J/ R8 v y# Z
}
# n; Z/ A3 ]* N0 t4 r: q' P
5 B+ S; n) U$ k3 lstatic void __exit led_platform_exit(void)- ^% o! R) s$ J3 m$ |9 R
{# s- x4 }( `9 q* G1 M
platform_device_unregister(&da850_evm_tl_leds_device);4 y7 t8 Y( q8 T+ l
* F0 e4 m* c% B) ~0 ]# Q printk(KERN_INFO "LED unregister!\n");
! F5 I. r" K8 D; O: Z! m$ ~}. }7 @. Y7 l4 F/ e6 B w3 D" J
4 X8 V5 x* J( umodule_init(led_platform_init);4 B# k5 W+ R# |: ~
module_exit(led_platform_exit);
0 D+ L2 Z# ^7 t7 W4 f& g+ l+ W# v; a0 S4 I' ?9 \! F
MODULE_DESCRIPTION("Led platform driver");* l' k# o( d6 U8 g* a3 z" ]" q
MODULE_AUTHOR("Tronlong");
3 p7 Y8 Y0 P) |& @( h/ rMODULE_LICENSE("GPL");
" e% n, d. L/ B! {) H7 y2 d" a8 W0 r
|
|