|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) Q3 p Z6 b9 s7 f, b#include <linux/init.h>
: c/ U y% @& H; y8 r8 R#include <linux/module.h>
# b* W- I0 a3 V5 R* C5 ]; x( X7 ~#include <linux/kernel.h>) C& V' L6 j& U- R
#include <linux/types.h>( x5 Y8 y- x1 E$ k6 m2 w
#include <linux/gpio.h>
5 p% M% b5 I+ I+ v; a0 C% n' K#include <linux/leds.h>0 t) ^$ \# C+ y% e) M( L" E6 c
#include <linux/platform_device.h>& [# U$ X8 s6 i# l
3 n. A/ m0 ?4 l#include <asm/mach-types.h>
- Y' p+ [! q8 M" E. P# ?#include <asm/mach/arch.h>/ H7 w; L( d- z
#include <mach/da8xx.h>( d0 s. h/ U4 F8 ?& s. j' [
#include <mach/mux.h>( h# _5 h m2 E" {
# z7 m/ { \2 g$ ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' W$ V: N2 f; C/ I" C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# V4 a2 G1 k8 ^% d0 R( _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); r0 \1 g) J7 J# v s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 L0 i( z8 t9 L4 ?4 x6 N
' c4 v S- t# h/* assign the tl som board LED-GPIOs*/
3 X8 y% V: ]& {: R. J5 pstatic const short da850_evm_tl_user_led_pins[] = {6 u+ M4 h5 ^7 D8 m% n7 B
/* These pins are definition at <mach/mux.h> file */
. A$ X3 I9 ^. { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) g4 M- L4 o6 W. j
-1
2 B2 n* Y4 S2 m) m- ~3 P. \( J" L};
& d+ j5 B# K' }
: C: M! s3 N' G5 hstatic struct gpio_led da850_evm_tl_leds[] = {& ]' `" |' P; e. P q# ~$ f; J* ^
{
! F N$ i% v4 T n& }7 j .active_low = 0,' ? ?, i0 p5 c0 Z
.gpio = DA850_USER_LED0,
5 ?. k! k2 F7 l, H .name = "user_led0",7 }9 b$ n# j2 S" Z
.default_trigger = "default-on",5 u9 M; C9 K: ~! f0 E8 \/ ]
},
% J+ p( Y4 i- J: e9 x {
, O* M1 m, U$ ~5 `3 j, y d .active_low = 0,
2 [2 {* x' C( G- d .gpio = DA850_USER_LED1,% s5 F9 R6 X$ a5 s1 y
.name = "user_led1",
2 h; F& @8 q/ i2 X( r .default_trigger = "default-on",
3 G$ D1 l# Q" l: L1 K },+ }! r1 m- E5 Q
{$ t5 I( |$ d4 l& [
.active_low = 0,
$ H) h+ }' H$ A0 N) s+ O7 A3 ~ .gpio = DA850_USER_LED2,
9 _: J2 ~" {- [) F$ N+ _$ M .name = "user_led2",
( N' r4 E t. ], J0 G H# T/ M .default_trigger = "default-on",
7 A% j4 ~6 j2 \! D },
( Q5 P0 H: i @& a# Q {) H L* f- } \" t7 w
.active_low = 0,
2 G# H6 J6 w1 f- g) E& C .gpio = DA850_USER_LED3,5 z# g0 z# V% r T9 S: c
.name = "user_led3",
* k4 z8 s$ `9 z$ G1 H6 ? .default_trigger = "default-on",
4 ^- k6 f9 w7 U' w( D },
6 f- Z- u$ v7 h% G* `3 O};* a, Y# {2 `! N4 h/ R1 G$ w+ ?- h
* e' ^7 F8 o1 C0 q4 u8 x$ ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ W, d5 |- \" X2 E/ x- F7 N6 A
.leds = da850_evm_tl_leds,
6 j @3 S. _9 E/ x% Y5 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# o& K6 s- C! H3 `};, ^; E# R9 k5 p5 X0 V# c. q9 r) ^
% L" h. p/ ^2 p2 s3 _' _static void led_dev_release(struct device *dev)
* v$ {# Z! ?% M( W' W{% F c- @ S7 m* K7 J1 e$ I; O7 ?
};
; s6 X* A/ z+ ]6 X6 |( |0 z
+ [: V6 t& w! w" e3 K+ j7 _' N, Tstatic struct platform_device da850_evm_tl_leds_device = {" V7 Z5 c w# s4 d5 R7 } M
.name = "leds-gpio",( i( I7 e/ k( R9 N9 n9 m& c
.id = 1,' L; m) T+ A5 |! D8 p% Q% u ~
.dev = {6 [. `& D5 T8 a2 p7 X9 \* E$ G
.platform_data = &da850_evm_tl_leds_pdata,
; L" v) n7 Y( r" B9 i: d/ \ .release = led_dev_release,6 L; ~# y! f5 j" O& I+ ^+ r1 P/ f0 A
}
4 U" e O1 ]1 C) ?! ~% o' j};9 b" B' P2 E: I
8 E& t- J; Z6 T$ ^2 M- t" Jstatic int __init led_platform_init(void)
- n/ v" [# L/ ]: }8 f# u% U1 u/ Z7 h- T{
4 c3 _ z& ~) P1 r5 j1 W& D# @9 ?1 _ int ret;; z0 V, ~: }: n n3 C
#if 0
' ~" H8 `# z, _/ J) P& n: V& w3 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 T2 O; {' i0 p8 E) J
if (ret)# z c# @" q8 {6 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" A, X ]( }* a
"%d\n", ret);& O B: E3 n$ u- p: a! C
#endif3 G' d6 |6 k6 {9 }: j4 t
ret = platform_device_register(&da850_evm_tl_leds_device);) I- K/ O5 q7 T+ d/ ?- K+ r' w4 u& o
if (ret)
5 m! S6 f ~* N% ^ pr_warning("Could not register som GPIO expander LEDS");
! b0 k5 K8 G. u7 C7 P; G else
$ A1 D. m* Y* C& R/ M4 v' z printk(KERN_INFO "LED register sucessful!\n");& |: F9 c, _1 L: t& k
% L1 [* K3 x3 [" G6 p return ret; ~( V5 O! F" A E
}+ [' h- p1 v4 N, ?
; U5 o5 j; \ A7 ]! Nstatic void __exit led_platform_exit(void)# l- |1 D0 \- J* {
{
4 d" M: r( L( v4 S, ] platform_device_unregister(&da850_evm_tl_leds_device);
- b( e. u, \2 L- b+ j) ], \3 z2 |
& T! S+ A8 {( l0 I4 r printk(KERN_INFO "LED unregister!\n");* p% G u M4 u+ S1 w) E7 N% \% w
}: W- O; ~4 l% {( F) x
; ?+ @0 f1 g! K) S% g4 m' H
module_init(led_platform_init);
: s; i" f" l: P& ~$ r+ tmodule_exit(led_platform_exit);
( Y9 T4 l8 M+ C% U# j' E' D: m/ i9 U! ~, m, j( H ~
MODULE_DESCRIPTION("Led platform driver");3 {- I) I3 O0 O4 L
MODULE_AUTHOR("Tronlong");
& C9 h4 [- Q+ n0 k% `4 T2 {MODULE_LICENSE("GPL");
! q8 N6 K) F9 Z3 i9 T7 }$ x2 [" m
|
|