|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 u: p" {( A# }8 Y. L#include <linux/init.h>5 \0 _7 f |5 n; y) R9 R& o- Z
#include <linux/module.h>
2 s7 Q' n. d. U0 E#include <linux/kernel.h>7 R' q) y7 t9 J T8 ~, F1 h
#include <linux/types.h>
- _/ W8 s7 R4 e+ |! Q#include <linux/gpio.h>; }) x$ Z0 p# h
#include <linux/leds.h>7 |0 ~( d8 U7 ]4 s& s5 O' f
#include <linux/platform_device.h>. t; q+ D) a4 W* k
% N0 O/ a+ ^' v4 \
#include <asm/mach-types.h>0 [5 ]% ?& {/ U. j8 _% }, ?
#include <asm/mach/arch.h>6 p! s9 P r6 P4 N, I% X" P
#include <mach/da8xx.h>* [' T; T7 [2 t2 { a
#include <mach/mux.h>
1 z$ r6 c1 r) d; Q C2 m( {( \+ v, c5 X3 r3 U0 g4 o+ }; ~5 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- U8 X! V: `4 ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 U9 m2 z3 [( x7 H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" J9 Y. r5 {+ S! Q3 y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 s! d4 c5 |$ [
, o. y& o7 s) ]4 h( E# V
/* assign the tl som board LED-GPIOs*/" H6 U, J* Z1 L; c; Z4 S
static const short da850_evm_tl_user_led_pins[] = {$ I2 P+ M& ^, S1 L# c! x! |, `
/* These pins are definition at <mach/mux.h> file */
: z! v2 S# ?8 Q/ L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& y+ H, u9 Z6 @, U g B" y
-19 J }- ^# W* b% _6 M' Y
};
: f; F l2 A+ B2 |# U
! y: a7 S1 M8 Vstatic struct gpio_led da850_evm_tl_leds[] = {
( a; U! D( i8 ?* X1 y {
) Q! X. U% s- F .active_low = 0,
& g5 o" G& [) E$ y# U$ C* m .gpio = DA850_USER_LED0,; c/ Q7 w, ]5 z$ E
.name = "user_led0",
; e; s* S) C7 ^/ v1 j6 v: k7 t0 ] .default_trigger = "default-on",2 `. L' t, K! ] [7 j
},
8 u: J" N# _# a; c: j6 Q, S" N; ^0 Y" v. u {! y- @: i4 n5 ^# s9 H J. }
.active_low = 0,
# X0 J$ x% w* O5 e9 h; @1 x .gpio = DA850_USER_LED1,/ x* I* n. H. r4 d
.name = "user_led1",. c& c/ E; K8 l/ }
.default_trigger = "default-on",/ ]9 P, C) Z, k1 `
},# D% i& M3 L' K* H. f" z2 @1 K
{
- z" I- B2 y5 X: R .active_low = 0,
% C; n s5 X8 c" X" @6 X* \0 W; k .gpio = DA850_USER_LED2,0 D6 ?" y# r( o3 n5 A
.name = "user_led2",, i7 ~- W* p3 J" h
.default_trigger = "default-on",
; M2 J5 H& `: f% y$ B3 E$ Q },
2 B9 [+ O0 f5 e! C6 s- T {
8 w$ f' q4 u& I6 Q% Z! @2 J( H .active_low = 0,
7 F% I/ L: P% T$ _8 d. N .gpio = DA850_USER_LED3,
: C {! p) [0 L0 h# `! k% O# z+ Y+ T .name = "user_led3",
+ ]' `$ n% f6 x) n( M2 D* H) | .default_trigger = "default-on",. X9 y5 X {; ~- p
},
- S9 f* b! x. C& K};
9 z) d2 _& X; D: P$ b# ?& R: i( c7 }' g9 Q, N: `4 k! @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, ^' l5 L/ Q! `9 F" u* k .leds = da850_evm_tl_leds,
$ f! `' l0 K# w5 y* Q7 L' R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 y; W0 Y B% e4 W+ t# j V
};
: b$ \7 u5 e4 J" {& r5 ~) h
; h* L6 G( o, D5 p9 p* S$ ~/ v4 ystatic void led_dev_release(struct device *dev)
: z# n, r& Z7 Z# Z& Y{$ w9 C0 Y2 e+ d- P
};9 y: }* D2 L- Y- N$ N W8 i
- L9 Q/ p; z, O6 i7 O7 }
static struct platform_device da850_evm_tl_leds_device = {
" D5 Z) Q. D3 k4 [' E .name = "leds-gpio",
6 @) B* `/ \& p- |" u& g' Y .id = 1,* x+ K8 j9 L1 d; A5 M' {1 U# [
.dev = {0 u9 {3 g# G, P, x2 M2 C" q6 t
.platform_data = &da850_evm_tl_leds_pdata,' o; r, l2 _, H" |2 w( J8 p) Z
.release = led_dev_release,: v- N( t$ m! K' k! `
}
4 s# v$ s2 ^9 e};
; K& {+ q4 P9 {8 c. u
* G, u- g9 z2 p! N. [, d$ h! _static int __init led_platform_init(void)4 ?* l! e: b* Q7 g
{1 M. k9 m& U% ~$ |6 s- ]; [9 `, H( P
int ret;
" W* l3 m4 d1 I' @#if 0
! {/ V, q! d0 D' C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- \9 c0 ~2 @6 W5 [# d* \3 O' |1 [' C5 O
if (ret)0 _4 K7 S: c, d* }4 r- S$ a# _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( B) M6 r$ {6 o0 o
"%d\n", ret);
0 g0 c. E! A" z/ Y#endif- C ]* f# K' |
ret = platform_device_register(&da850_evm_tl_leds_device);
9 k: S4 V. p/ ~- [; l4 T if (ret)' b# F! Q7 a' o+ C3 u
pr_warning("Could not register som GPIO expander LEDS");1 l4 Y* O2 d6 F
else! K" Z4 J9 m5 C& |# l
printk(KERN_INFO "LED register sucessful!\n");
. l6 W# o6 h0 @; f M/ L
! B7 \5 Y: d& l" P3 r return ret;# ]2 c8 ]' V0 }0 B& O' Y
}( I4 \: X; Z2 b- M& d, r
' j O' U9 o) G( ~4 |
static void __exit led_platform_exit(void)/ V- C9 w1 T: Z1 L$ w3 z, L
{+ L2 x- K1 H# g l) m- V5 k
platform_device_unregister(&da850_evm_tl_leds_device);. o6 T7 ]8 o; Y) }+ U, h5 o
# P8 | Z- s5 y- x" Q
printk(KERN_INFO "LED unregister!\n");
! ~4 j, ?1 Q* I# O- |4 N}
& p2 V. u/ }& v0 j) N0 C3 I; v' L* I. R9 s! B2 `! n
module_init(led_platform_init); t" J# w8 J9 ?. X1 F' L
module_exit(led_platform_exit);2 @1 Y' b6 C0 @
" Z! Q5 `1 W' i! ?% e$ Y* E8 |1 I( NMODULE_DESCRIPTION("Led platform driver");
. z! _/ ]" J$ l! `MODULE_AUTHOR("Tronlong");, Y' F+ `6 u8 R ?8 a5 E4 G
MODULE_LICENSE("GPL");
5 @8 }0 ?6 y+ i C5 M' m% T- u! k4 s' j) ^! ?- E+ g
|
|