|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' u; [# r/ v& Y U7 m# ]
#include <linux/init.h>6 G# M: H7 e2 z* y0 K; a) Y# G
#include <linux/module.h>; ^6 k: M1 }( g9 T4 Z, v
#include <linux/kernel.h>
7 {, F3 l1 Y; ]1 w' O2 C* a#include <linux/types.h>
2 L, X/ `: }- `#include <linux/gpio.h>% v6 \8 U3 L, A, N G/ N
#include <linux/leds.h>9 Q3 v' E- r1 a3 ?" L$ ?
#include <linux/platform_device.h>2 H" W, v6 X/ w4 W0 U+ x
5 x; H$ i: b0 y z#include <asm/mach-types.h>( f/ L" C2 ]. n, k
#include <asm/mach/arch.h>& y# g2 Z4 M$ Q
#include <mach/da8xx.h>
: T! ]. C( `$ E' h#include <mach/mux.h>
/ @: [( v4 i) _" N$ o) D0 [: X
! M: z, d7 _2 g- S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! Z P2 o8 Y7 x) Z3 K. p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( C2 e5 i: T0 a4 C1 R: v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& I3 e4 t6 o$ E* w5 @/ M9 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) w* F9 O* d" S6 L
, Y; y) Q% i3 }0 f* `; C0 Q/* assign the tl som board LED-GPIOs*/
1 t/ n' m1 Y" cstatic const short da850_evm_tl_user_led_pins[] = {
6 e" h/ r$ Z& \& _% w /* These pins are definition at <mach/mux.h> file */0 Y, ]8 M9 |2 Y+ M6 S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 l) c5 O- p) v/ U2 t0 l3 [ -1
" [9 E9 S& S, l) U};
4 R6 \3 V% T2 q* \6 C5 A7 H) N* F! f! h, y D
static struct gpio_led da850_evm_tl_leds[] = {" W' s; F* b5 b% q: d! l
{
# R7 _& H( N! u6 D, H- Z .active_low = 0,' j, a: F! J- R2 U9 `3 Y
.gpio = DA850_USER_LED0,7 m, U. m+ N8 K, Y/ _
.name = "user_led0",1 `& y4 C4 _9 t! ?
.default_trigger = "default-on",
/ D |; e: s) o7 U! ^4 @! n },- m3 u; W* s. b2 r6 j3 N) h" n
{
3 f6 C, X; L7 u, p* r9 v' E .active_low = 0,$ T5 z; {; [% p* ^+ ]9 `
.gpio = DA850_USER_LED1,
8 Y& Z" Z/ q1 n& N( }5 e .name = "user_led1",
3 V; D1 }# J! S0 ^9 l, Y: G: u .default_trigger = "default-on",2 @4 |- E6 ]# ]. @4 L& Z. e' N
},# u% ~% [0 s4 @
{
" E7 v, G% p6 |4 D, e .active_low = 0,. G# Y( g7 B$ A7 Z d6 T% |
.gpio = DA850_USER_LED2,# M4 _1 F }+ u$ j: y" E
.name = "user_led2",
0 v( l: `/ S/ P1 ]" {; O .default_trigger = "default-on",! L) |6 {2 ]0 D; E8 g& d6 i7 C
},
* P) t' W9 H: [4 S9 c8 b {
. _' [; I5 W. n9 a .active_low = 0,! G8 \5 o. m/ h4 f- V
.gpio = DA850_USER_LED3,; |$ {# u, J2 g) R: _) l% [
.name = "user_led3",
h) G/ O+ L" L0 h# @0 M8 `3 a .default_trigger = "default-on",
9 q1 D$ v# B7 _9 Y },0 ~( M- E) U& h( z( s8 I2 F$ _
};9 n4 M( z) P5 T( N+ U2 {/ l
% b* ^1 p% g/ z% U$ U T2 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ W# `. v4 L9 |+ }" N: N% _+ c) \$ i7 n
.leds = da850_evm_tl_leds,& u J+ p* p3 t6 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 s7 R5 M% k0 y" {7 B- G6 N};
2 h' }5 u5 _4 J0 ~0 o
" v) e& h: ?' ]8 X- Y$ ostatic void led_dev_release(struct device *dev)
- w4 i' T8 r2 _0 j5 {! f+ w{
( t1 k+ i; l: S7 P/ [1 {};6 @7 W, u1 O. }
% B2 b; e) s+ p8 H# f) H. B4 Dstatic struct platform_device da850_evm_tl_leds_device = {' H3 C4 J' x+ _( S7 a6 N9 t* I7 `
.name = "leds-gpio",
0 _) G4 I1 N- x1 Q- G) c% ^6 B .id = 1,
1 M- |9 x* B4 u .dev = {9 L. Z* i n# S) N7 ^8 q
.platform_data = &da850_evm_tl_leds_pdata,# E& A, U4 a, y# f: x; _! g
.release = led_dev_release,
' t: H Z7 x) a0 b" {( I5 ^9 g }
2 J; ]+ T' u3 v7 r};7 E) z5 m2 j6 {8 g9 [5 R; u
$ B( q5 H# u; k( @( Q* e- W! kstatic int __init led_platform_init(void)
$ b" ?- s3 R% D$ R{
! E' ?9 {4 ?+ q' W: W int ret;
+ V( j- I: R- {" U- D' J I. X6 Q#if 0
3 {6 c$ l7 H. {4 H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% ~; Z( s- K/ n' U) _
if (ret)
0 x8 c8 y! L- u( m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 f# g$ K/ c/ b; G5 j/ a: n7 H "%d\n", ret);
7 S z0 }* Z5 _& S z% ]- M#endif
4 [! @, V* I& D$ Y7 S$ s. @ ret = platform_device_register(&da850_evm_tl_leds_device);
' s( i' K) Z1 R: a if (ret): s) m% F @2 J" [
pr_warning("Could not register som GPIO expander LEDS");
3 ]; T& U0 e u$ K else
: H: Z& J+ Z7 i- s) z printk(KERN_INFO "LED register sucessful!\n");+ | n4 {8 j }0 x
$ A2 F; g1 h" O& x, g1 y ` return ret;
; X! d( q4 D) b( ~# n$ T# V}7 d, G4 m3 w/ W; |+ l+ n
9 L& D* f4 B2 }
static void __exit led_platform_exit(void)
3 N, t) f( }* T{
0 Y( R4 F' ~+ C9 ?5 r+ T J platform_device_unregister(&da850_evm_tl_leds_device);/ S! J7 Z% m1 l+ m
2 [5 a: U' S; @. H' O printk(KERN_INFO "LED unregister!\n");4 D& W+ w8 L9 {
}0 b1 h, d$ P4 y7 C$ `
2 ]' P' J/ \4 B$ K/ _+ C x
module_init(led_platform_init);
8 o/ Q: J' N9 @: c" Kmodule_exit(led_platform_exit);
: b2 ]& d& _' Y1 K/ G& B, l: k* x9 i1 t. M4 d
MODULE_DESCRIPTION("Led platform driver");
. e% _' e( j0 ~ O6 D fMODULE_AUTHOR("Tronlong");0 n. l$ K6 S9 g, R5 J) w$ n
MODULE_LICENSE("GPL");7 A# d5 J( E2 Y; ?
1 u; v/ i7 G9 [
|
|