|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) q$ }2 A/ {! F u, z9 i! o4 [; B
#include <linux/init.h>
`" R2 X& d6 W5 O6 o* \( x#include <linux/module.h>7 A" C# V. J( h/ q- ?1 e4 g
#include <linux/kernel.h>8 X" `& t9 B! r$ I
#include <linux/types.h>9 h5 t+ }: @- d/ U$ ~
#include <linux/gpio.h>
; l; R7 N7 N$ J( R% l: r) y#include <linux/leds.h>+ q% c' H% W U1 G, Y# w2 j& m0 A
#include <linux/platform_device.h>
& E0 r. s- V" u! b) s7 j3 n- Z( l, F `1 V
#include <asm/mach-types.h>
5 {- N1 E8 d( P C8 X' d#include <asm/mach/arch.h>' Q$ u T" B% I" O
#include <mach/da8xx.h>
p/ Z0 C9 @3 y# R#include <mach/mux.h>1 S% q. y/ B! Y
& p' [6 o7 X- Q/ q N8 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 M( N# f5 c" h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) d* z2 L* C/ Z! C- t' r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; Z) b! c |. n1 B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* {$ T0 o: v- O& _ C: h
" J( y/ O( ]6 N, A
/* assign the tl som board LED-GPIOs*/2 s( x- ]; l: y! g+ k& B
static const short da850_evm_tl_user_led_pins[] = {
4 D$ ?) G: U" m+ l /* These pins are definition at <mach/mux.h> file */
8 F! f p% I4 ~) l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ |* X) U: J% l! {7 B; z2 \ -1; E" B% I: H" V' j/ j( ~1 w
};
$ q: Q/ N" U( Z0 O1 M8 M, t. Y+ L- C$ E" E: L8 }6 N$ P0 w, `: Q7 Z0 r
static struct gpio_led da850_evm_tl_leds[] = {; \% S7 G/ m# Y; e$ @
{0 b4 h' r# U, j0 f6 _
.active_low = 0,4 z, `+ H) W0 e
.gpio = DA850_USER_LED0,$ a( l5 b8 Q) l# P. e
.name = "user_led0",% y! Y1 k' Y4 }/ d
.default_trigger = "default-on",
3 o; a4 U4 V% T% c5 l- ? },1 Z4 J1 d- L( h m0 s
{
3 S8 l4 L e% B .active_low = 0,
E; s; C6 n4 r .gpio = DA850_USER_LED1,
6 a1 X; |* [* I- f .name = "user_led1",4 @( \/ c! C) J* N+ E" h
.default_trigger = "default-on"," k. T8 C& G1 t+ D7 Z5 f7 M
},! b) h$ l% Y) P$ E5 ]$ ]
{
( g( }/ o6 L( s l7 Q .active_low = 0,
7 O B/ Y* Z9 V3 w .gpio = DA850_USER_LED2,
! y2 n+ Q4 U9 z/ B2 M .name = "user_led2",( J W: v8 p! K! p
.default_trigger = "default-on",
" N* H! o0 w, }3 m. ? },
6 [" ^' M% N# m7 }) m, p/ ^ {
& J. v4 U( y; n7 t0 K! e .active_low = 0,
& d# T6 J2 C6 b3 p .gpio = DA850_USER_LED3,
0 B7 f8 N! u; c+ U3 N .name = "user_led3",: }3 g; Y& i( T
.default_trigger = "default-on",4 ]* O9 c% W# v _7 Y4 r6 t
},8 u& C9 {* D K% [( q- ]/ k
};
, m5 V0 V) h; C& n( t' y7 T& K/ y2 R! Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! l+ n2 @. M' J9 A. f
.leds = da850_evm_tl_leds,. }: X2 k4 b2 W+ g& W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- h6 U6 k6 V4 Z0 X
};- ~- e- r/ q6 S# Z& j1 R
E4 H9 M; y2 z* g
static void led_dev_release(struct device *dev)# w2 ]8 n$ v, _7 W1 z
{
* s2 ?% c9 N, ^6 a3 J4 F7 [};' x4 j6 c) l7 C2 E5 L: V9 u- v8 [3 p2 T
3 Y3 A% m4 Y" Kstatic struct platform_device da850_evm_tl_leds_device = {
% m: z- K6 D/ {" k* g, s- T .name = "leds-gpio",0 X3 ~4 {3 {" e6 s8 L+ r
.id = 1,
2 Y' x4 ]- R5 w, l .dev = {
- w! C& W) D% E! N4 h .platform_data = &da850_evm_tl_leds_pdata,% a; _9 T" [2 @6 R0 H8 l4 K7 M
.release = led_dev_release,
' y1 m$ ?. f1 |2 G- w' |5 ] }
5 f8 u) ~# R6 W5 M: w: E};
9 ]6 w! R0 M) m# q5 y, ~* B. M6 j
8 Z2 i( w- t, h5 E- |! j* J/ j, V$ Dstatic int __init led_platform_init(void)
) T! d+ ?9 k' s: M9 R' h5 R# `{
; j3 J4 Q0 L+ N4 Z- Q: x$ R/ E int ret;$ C5 P8 {& H) @/ B {: s
#if 0
# |) P. ^. k( ~3 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# x3 Z& Y- A1 L
if (ret)
e P- o7 n2 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% ^9 z. p* q$ f6 Q/ h "%d\n", ret);2 r0 W5 F8 [1 N, H) J3 ]
#endif
6 F/ v1 M' ^ t* J* C4 N( ? ret = platform_device_register(&da850_evm_tl_leds_device);8 J6 k# ~ g( `3 K8 {9 x6 L
if (ret)6 p- r" O: o" f6 Q" k. l
pr_warning("Could not register som GPIO expander LEDS");
" p# R8 L, m% t' Q else* w" q+ W4 ?' C& R& Q/ |: u
printk(KERN_INFO "LED register sucessful!\n");" H: |1 ?) N9 U' ~: i
$ K2 X8 d1 U: P return ret;& C8 I+ S9 e+ p& C2 F6 v6 B
}( d- t! u% y& E) Y2 a
- X4 I8 {% @8 |2 {/ G. M4 V6 x2 T
static void __exit led_platform_exit(void)4 m' e% z7 |- m$ z$ Z! y
{5 i; [3 H+ z5 k
platform_device_unregister(&da850_evm_tl_leds_device);
$ p h7 ]4 f8 m/ l' @2 X/ y- B
- P, k4 Y( P. J" I printk(KERN_INFO "LED unregister!\n");
! F: T2 Q: [' L9 q6 ^) O: h}- H5 e$ W9 j! Z" h/ A% N3 t
" e7 K0 X5 u4 @0 o1 Mmodule_init(led_platform_init);
( z3 a" X7 E8 R4 S" a! } C9 y Imodule_exit(led_platform_exit);# [5 b% s* M9 n6 \& S6 k4 ]% }3 O
$ X8 w7 d* Z0 O: J% `MODULE_DESCRIPTION("Led platform driver");
# A9 C' l# D4 \3 GMODULE_AUTHOR("Tronlong");/ \; M% k) ^! L
MODULE_LICENSE("GPL");( f6 N/ n6 W; v- t+ G8 T/ Q; g- d: `
$ r, c7 z% f5 u2 F- B( y0 p6 _5 |
|
|