|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 l/ X% h" |1 e n- g
#include <linux/init.h>- V6 S5 U; S( r/ o
#include <linux/module.h>
; `. o$ w4 t6 C0 G0 x& N, g#include <linux/kernel.h>) B1 \; w$ s% P- _7 Q8 x3 \- r; |
#include <linux/types.h>9 }0 w( j" u% p9 p2 U: f A
#include <linux/gpio.h>
; h2 K( k% h1 D% U* `#include <linux/leds.h>. a! P' N( j% g& i5 |! t
#include <linux/platform_device.h> X- p8 i+ O0 R: s6 n
% y" w; r4 I& p( e
#include <asm/mach-types.h>9 \5 x1 @6 O/ Z6 L# N
#include <asm/mach/arch.h>6 p* }/ \5 z' b& |8 H% |7 P2 Z
#include <mach/da8xx.h>
; |( i2 A, Z# A3 B1 ~- N#include <mach/mux.h>. F2 n0 M! K/ r7 W4 L( L
6 a) o& i7 m7 f' ~' p v$ r- h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% J: P6 C& C+ d7 ^# B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% r, v2 r8 R& w+ ^2 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% Z. x7 L" w# X& K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" R. v ~5 v6 \; ~
0 U% {- n9 x% V% h0 I/* assign the tl som board LED-GPIOs*/7 o3 \* F$ \! i2 ~4 c1 M3 s% w$ `
static const short da850_evm_tl_user_led_pins[] = {
/ h% S; O; }: y6 x( R) V7 I5 x- T: [ /* These pins are definition at <mach/mux.h> file */
; F3 e3 f) X) ~, u) R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, R7 i1 G; n: A3 `3 c1 G: A+ [
-1
/ b3 N/ ?8 L& z! N& g};
6 @3 ?+ r( H5 m$ e- [% ]) m6 M0 x( B; G3 q p
static struct gpio_led da850_evm_tl_leds[] = {
$ K; z Z( c% Y7 F' C {
; T3 o5 I* X2 E3 }, ~/ Q+ j .active_low = 0,
/ `$ y ?5 L: t Q i .gpio = DA850_USER_LED0,
* u, P: Z8 |$ l" b .name = "user_led0",
* E' C6 m$ L' J: |. a. g .default_trigger = "default-on",
9 d3 L5 a6 M; J& a+ L( \( m },: v( @1 b" c( i* _9 I- O
{) q& @# `0 a1 r7 `7 u
.active_low = 0,2 Z9 |( m# h# g% A
.gpio = DA850_USER_LED1,
3 T/ s7 n! {, V' t .name = "user_led1",' s+ I4 m3 A9 |( Y0 }
.default_trigger = "default-on",
# t4 r; S& T' G z8 J$ q },
0 h$ ~3 F( ~$ r- T6 V {- [, Y- q, w: d7 y! e
.active_low = 0,5 _( a$ B' Z+ |% e$ N1 |
.gpio = DA850_USER_LED2,
8 ~* [% ?2 G5 P, G .name = "user_led2",+ K: I& w0 Y8 r# j( r: B$ d
.default_trigger = "default-on",
% p, O2 c- q) A9 v },
. V- F5 j; o# @) B {
+ _: Y5 p: t( {5 E( ~3 g+ V .active_low = 0,0 ?$ I! o* R# s* f7 C1 t
.gpio = DA850_USER_LED3,: h7 Z4 |6 |2 j4 M7 f1 `
.name = "user_led3",9 X, @8 K/ Q8 r5 Y R. Q! b4 ~& r+ `
.default_trigger = "default-on",7 [) _* O( X) B" N! B+ E4 ?0 i
},' B4 u( Y* h( I& Y/ J
};
6 J3 |9 s7 @' S" F1 H; J' M1 s* z2 `) H2 y- i4 a% w& G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ V( M( j1 p- e. I0 B+ ]
.leds = da850_evm_tl_leds,
9 C$ f2 [' b s+ N6 R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ \% V; ^, ^4 U: D# i5 _};; W/ u& Q' [8 W# J
; Y( B/ a; r& d$ pstatic void led_dev_release(struct device *dev)
/ P" M3 e" j' ]{' n* k0 [- `5 b5 J" v) E `! w
};: ~# b* D- F& p
& q) _* c }. \& sstatic struct platform_device da850_evm_tl_leds_device = { @. i S8 i, \1 f1 [( x$ I
.name = "leds-gpio",9 Q0 h& q7 q, G+ P. c
.id = 1,
- e; q8 {5 C* L: {/ D9 a .dev = {/ L9 w- N+ e7 j( X
.platform_data = &da850_evm_tl_leds_pdata,3 C, ?5 R8 o2 j1 |) M% d0 J
.release = led_dev_release,/ l- y8 R( W, k: M: J5 [+ N
}) [8 `" [0 Y2 M( ~% x
};7 Y& ^& X- W. L' [
7 x4 Y* k! n3 c/ a- y
static int __init led_platform_init(void)
) }, o( F' U: X& ^{
- }: q& i" [6 c$ v- l& S( L int ret;
& {) R! O/ D7 B9 U; `; y K+ q- x#if 0
4 m9 R k) B2 j/ Y/ M# O# Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 ]: f: Q: u+ t+ {7 b; \) C/ a
if (ret)
# t) X& ^3 M, n+ D+ o5 ?3 r0 f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' N5 `3 @, n6 h- j$ \" m
"%d\n", ret);* F; j9 G/ k& C5 p, l7 T }. T; \5 V
#endif
; H, G( F: U* z4 X ret = platform_device_register(&da850_evm_tl_leds_device);
5 V5 N# N' I1 W/ d% g5 O8 L if (ret), @5 _: k' h( H* z6 ^
pr_warning("Could not register som GPIO expander LEDS");
w5 N8 D0 `7 v7 l; _) y else
8 M/ s4 [9 Q# r5 T3 ]4 _0 I' _. U printk(KERN_INFO "LED register sucessful!\n");7 L' J+ C" D- \3 s) {, E
8 N! l* I/ k# R2 l3 [5 X3 G' s
return ret;
2 Z5 L( E6 \/ H, U3 s8 z}
: O# x) {+ g( l5 M& f
/ n5 A$ ~$ L- D+ m! L1 e' Zstatic void __exit led_platform_exit(void)
& v# Z. s. V5 t+ ?{. d7 d7 \- e7 B8 {; H9 Y
platform_device_unregister(&da850_evm_tl_leds_device);
9 [# d7 ~1 E! ~ I0 Q4 z6 s8 t& T! x; s3 h
printk(KERN_INFO "LED unregister!\n");
5 K, B( ^& E4 b: N) q: K}
" }$ V E$ M& B
3 A3 }4 Y, u: u* Fmodule_init(led_platform_init);
* [( ]' v; @) i3 ?7 ^module_exit(led_platform_exit);7 w+ ]5 D% y# t
5 U% U2 _) |+ w2 w' H# o9 sMODULE_DESCRIPTION("Led platform driver");
; Q/ X4 n) Y* ^4 n& z/ Y7 {# HMODULE_AUTHOR("Tronlong");
7 h) i7 v2 ~- B5 @6 RMODULE_LICENSE("GPL");, p/ G4 X6 P* `, V6 S- z- _" }6 o$ G
# T9 e, D+ W' i3 X6 i! ]! Q1 G4 r |
|