|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" F- m+ V" Q! y7 g) D
#include <linux/init.h>- H# _: l( K; j/ z; \
#include <linux/module.h>/ M) z2 B) C A k
#include <linux/kernel.h>
: v9 d4 U+ N, H0 Z- r#include <linux/types.h>
+ K* a. A" @4 r& }' w0 b ?; j6 W#include <linux/gpio.h>+ j4 _4 B! }7 `2 q4 R+ o
#include <linux/leds.h>
, S8 U; Q5 `! x4 p* U4 d3 P4 `4 H#include <linux/platform_device.h>: w* t ~; O; j/ H c% W+ |5 q: I
0 d, ?% }( m) a1 _' L
#include <asm/mach-types.h>8 s2 j8 U' c& l% T, g
#include <asm/mach/arch.h>0 H" ]+ q+ r ]- J
#include <mach/da8xx.h>
2 Z- [6 S, }1 z8 d/ X#include <mach/mux.h>
& {( g8 u0 G- V" s) _
0 D, @( J- ~, [9 X9 |% S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& V2 o$ V4 o4 q! H' m$ s- b. ^# `+ _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( n) Y8 ?! m7 N/ p# C+ B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 n+ A+ [' a) D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 x$ E: D7 s5 o+ n
. ?! c g% a% v& R4 z/* assign the tl som board LED-GPIOs*/
7 {7 B. P4 q! D* a- P ~0 [- |static const short da850_evm_tl_user_led_pins[] = {& U, j' A: f5 l! _' K# Y
/* These pins are definition at <mach/mux.h> file */
& r' Q$ S$ x p5 p/ b! x3 K( I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ S2 `, U z4 f- ]$ L! R* Q -1
8 m8 h+ o6 p! | G8 E};
; o1 B* u8 a0 D) L5 ~9 i
/ g" I* `% b6 {0 ]6 rstatic struct gpio_led da850_evm_tl_leds[] = {; L" `% N; t! q
{
" Y0 \) _) y: M( ?6 l4 B+ Q5 l' L .active_low = 0,, e4 j6 P: W# w2 m1 y% K: F: y4 I
.gpio = DA850_USER_LED0,8 D' E2 o4 t# Y5 Q$ w6 N5 E4 Y% u' [
.name = "user_led0",7 E" o. d3 o; J3 Y/ I
.default_trigger = "default-on",
' |! A( F& E( R' } },4 J8 c" [& N6 Q
{
$ W: \+ n& Y! O* R0 [1 {6 P .active_low = 0,$ l% r& F. M6 s7 U5 P
.gpio = DA850_USER_LED1,( _. K! Z9 W; _4 Y* S
.name = "user_led1",/ Q7 `# _0 H5 K5 [- L$ r
.default_trigger = "default-on",
# I# K. l2 l) V4 U; n% C },
: `7 E- f# `, r( R) [ {
+ l0 J5 D. e0 F. P* `# a .active_low = 0,% f9 ~/ @0 o% i1 s: b) r
.gpio = DA850_USER_LED2,
6 k( d+ q& y3 C$ j8 t( ~$ ] .name = "user_led2",# k' a9 n {& J* R/ j+ D2 f' T
.default_trigger = "default-on",
( F- m, \! l0 @# G$ ^" a u# L5 F: x. v },
; e0 L# `( m8 j3 o7 D {5 |1 f, w2 X' i) Y
.active_low = 0,( W7 d2 X3 H3 f7 n4 D9 U# |& k
.gpio = DA850_USER_LED3,, y! L0 X" X% L z6 I
.name = "user_led3",
' A/ r1 k; v& j$ a1 F. U/ \" |) Q .default_trigger = "default-on",$ I! V& @& _7 p( P
},0 v4 x/ l+ r. U6 G" D4 h! q
};
$ k3 y) t' g* x: x4 W+ @" p* \$ d; L0 ]% v" E% l% R3 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( r, o. h$ z3 T8 |" B
.leds = da850_evm_tl_leds,
( T6 Y$ z, i5 p7 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* A/ ^9 H& O6 C* z3 K* _};1 u4 I: b5 q0 d8 F: P
7 d* q) t2 h3 N) P3 N$ `, {- gstatic void led_dev_release(struct device *dev)
! X. ^ n w# g: m2 X' n7 Y{4 z8 \) n' K4 e" g# ~
};
# a+ R2 ?( {) w+ V5 Z/ o
5 e7 @2 q3 }* m2 ~static struct platform_device da850_evm_tl_leds_device = {
8 S3 h( M0 O9 @. ~$ h$ E/ P3 I .name = "leds-gpio",
8 f- Q* j6 h' A3 Y9 T .id = 1,* ~ h' W# B' C r4 {
.dev = {
" ^- p0 M) W5 V" {+ ?( X. {( f .platform_data = &da850_evm_tl_leds_pdata,
6 j' J/ z6 ?8 R. o+ ? .release = led_dev_release,1 X4 M8 {# y0 a& [. x9 @
}
- Y6 ?5 B) b1 i/ K! W* P/ C};
+ p, r3 V% ^9 o6 S" Q1 ~$ ~# V, X' O, F5 K5 f& K5 @" G0 F
static int __init led_platform_init(void)9 a, u' w( J z, C/ @
{
4 Y6 c! t3 `( C z Z# L int ret;+ M5 C4 `. k8 [+ M
#if 0
0 O/ h! Y5 a2 ~) @( Q3 T# L" \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" Z1 R! `7 L3 ] if (ret); P% K2 B: j9 n3 [4 W! u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 T/ z9 e& Q5 J- Z
"%d\n", ret);! ?% e8 z- V$ a, l* Q1 U7 E6 J
#endif& S2 C+ A6 ? H# y' U
ret = platform_device_register(&da850_evm_tl_leds_device);
$ |4 K5 I4 O4 P& R1 j' u if (ret); x: f' d/ P( g' Z
pr_warning("Could not register som GPIO expander LEDS");
: |( y, s. _' x2 c1 a0 S: L else7 ]; t0 A" Y/ e% F' G
printk(KERN_INFO "LED register sucessful!\n");
: E# j' X# K. F" t$ O2 v. [6 c2 L) X2 s# {* |' B
return ret;
0 J O; N% R5 j# v) l' J3 T: N}
* r, C1 {% W5 V6 D' j* Y$ W; e+ \4 |5 @. l) M
static void __exit led_platform_exit(void)
( s3 r: |3 {; m{9 s, T; a J+ F( X% c
platform_device_unregister(&da850_evm_tl_leds_device);
9 i+ l+ F: M3 v3 F
" M6 i% Q2 }3 `) L% j: s1 r printk(KERN_INFO "LED unregister!\n");" O3 o: r& F+ Z
}
) L. E; ~' `4 V( U
5 l5 J6 g9 `5 X1 K. j9 `& k3 P8 Hmodule_init(led_platform_init);+ s' F" \; b; g1 ~9 m
module_exit(led_platform_exit);
& _& M% m! z4 h& r2 P* H! @
; k6 C$ O, S6 `5 }MODULE_DESCRIPTION("Led platform driver");
9 v& `) h# n1 u6 pMODULE_AUTHOR("Tronlong");& [* g/ _. P6 b _) t3 e
MODULE_LICENSE("GPL");; |8 v- d) r$ x( ?. f
4 N# b0 U9 H) @ |
|