|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 a& X& O; `, H9 j- d" E8 j#include <linux/init.h>" @. c4 ]5 ~1 Z
#include <linux/module.h>
# E" G( `- w; ]8 E# J8 M2 p: j#include <linux/kernel.h>
# F: L l. ?% m t3 m* ]3 L9 n' e7 t' L#include <linux/types.h>* s. }# \# E2 f! s& T3 W! @+ a! f
#include <linux/gpio.h>
* B( \* l0 S+ A: d#include <linux/leds.h>
% J* ?4 i: s; x: U, ?6 v+ o; ]#include <linux/platform_device.h>! E/ k6 e, Q# H+ v& [( s$ u( t, p0 D- [
' {: Q8 X' p) c! h, ^4 m/ w& S3 g
#include <asm/mach-types.h>/ e6 O6 W; g8 o; X- V! `( \
#include <asm/mach/arch.h>7 m5 @6 m" I/ C& j5 z: o- |) F9 R- j
#include <mach/da8xx.h>
# I; s' l: ]: y#include <mach/mux.h>
4 q7 a9 H1 P' K$ T
9 W$ E% y/ q7 }6 {" [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- M, K3 O3 t- a8 o( B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% W( k4 a( q. T8 ~2 f* \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, ^' C2 ?' F* B' z1 a5 F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 e) \5 H' p% O8 g
' ^: k7 r! d* ]/* assign the tl som board LED-GPIOs*/
4 }" [% I# P& j- xstatic const short da850_evm_tl_user_led_pins[] = {- v8 N; x" r. ?+ U9 O/ K
/* These pins are definition at <mach/mux.h> file */% w( M: G( w% c( Q3 W% a, n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) v' V1 V1 u$ P
-1
8 D: N! B1 Q' R* f};1 X* c/ g& w8 g' K" J8 ], {
7 I5 F* p% ]/ M8 @3 J' {* b9 tstatic struct gpio_led da850_evm_tl_leds[] = {
" C( S/ _( k, d8 Q q! f1 v P. Z$ Q" h {8 L- F( Z/ Q8 v0 c- n9 H% Q
.active_low = 0,: b# @9 ^# Y2 I6 v, [
.gpio = DA850_USER_LED0,/ b+ K& U$ q+ I0 Q4 d$ n
.name = "user_led0",% c0 \) \* T7 j7 u7 M9 H, s
.default_trigger = "default-on",
) @& T& _" G8 a, m% h8 x, y+ ^7 q% S },# W0 a/ `, M& G; F( N
{& }6 t- ^! {0 \$ R$ L
.active_low = 0,
8 F) T a6 o, R .gpio = DA850_USER_LED1,- {! n. T; R9 j7 P; O
.name = "user_led1",/ z* e1 ?, w. u# E$ e2 F/ h r& s
.default_trigger = "default-on",- [, m8 @ T# b3 s7 a5 e0 H N
},# G; n9 t# V0 y$ r
{- t2 d8 D/ N) w+ C' k' `6 q
.active_low = 0,
; u: i% H1 |) T$ e .gpio = DA850_USER_LED2,
$ B* C/ R7 @- k9 ?8 U: T: D) y .name = "user_led2",
& ], E1 [3 f8 {5 J .default_trigger = "default-on",
7 f# @, n3 O" t& y9 G },! M" B: `% b5 W% ?5 P6 |
{# Y1 f* [( Z: m& s i+ D4 B
.active_low = 0,+ m" R! u! o. C! i/ t$ Z
.gpio = DA850_USER_LED3,
! q1 F' W, a! s4 q* N2 S* ?# b .name = "user_led3",$ T6 `" t9 P j& c( C5 V1 ?/ j0 N
.default_trigger = "default-on",' t/ z. R& X4 b5 o8 @
},
5 r# [; f3 l5 n! ~- N};9 g3 e8 c& E: M0 L6 f5 c! h
7 t* r/ s+ X2 m* E% ?' sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) C- L3 v- ~7 m6 K( N- z6 r, a
.leds = da850_evm_tl_leds,
- v3 M" X$ S$ X! { j" b. M& R7 \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ `. o% X4 c7 ?2 X' m/ f};* D7 Q" M5 x& b+ Q7 B6 |5 m: ?
T7 g+ P+ P2 J+ q W
static void led_dev_release(struct device *dev) u: N, J$ X2 z& G
{
- n3 D; A$ t7 s% R% j: y& f$ _};
0 O0 ?6 e: ~5 i6 r8 L- V4 V" z5 d& K- w9 y( e0 y7 l* B
static struct platform_device da850_evm_tl_leds_device = {
# I* r( i! l9 y$ \- R! ] .name = "leds-gpio",
0 h3 E+ b: q; q .id = 1,
/ K" r1 c- L; D, Q .dev = {5 J+ n( [2 A$ D' _- U5 D% `
.platform_data = &da850_evm_tl_leds_pdata,
) E8 u: s& H k* ?. M .release = led_dev_release,
' f2 j( \% P: J/ q }
3 l8 n8 M9 T5 v8 H& H% J2 Z/ p% t};- D1 i& [. ?5 Y/ u
# f; o1 o' k7 K
static int __init led_platform_init(void)
8 D2 S, k2 w* V. N: b{% F. `& S; g! q) Q* m9 h, e }
int ret;& O/ W8 M8 e, e
#if 04 t* \4 |* M0 X8 ^/ L# C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ~8 _$ Y9 g' i' b- ]0 F) f7 O
if (ret)1 |/ w) f& o$ w J8 W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 E$ i+ T, b& ?# a0 U" I9 q
"%d\n", ret);: |6 ?/ O. F/ d
#endif, H' k7 c1 t8 b) ~, z
ret = platform_device_register(&da850_evm_tl_leds_device);
6 n$ G( q7 i; S5 L. I! ] if (ret)/ H0 h! l/ S z* G% Z
pr_warning("Could not register som GPIO expander LEDS");& N- A, S' F7 M/ z
else
5 E. M9 \4 g, H9 `1 V; p$ H# @ printk(KERN_INFO "LED register sucessful!\n");4 K9 W' R% ~/ P9 j# H' ^
$ a( h7 q, v5 X. q$ O' _7 K return ret;
: ?- w8 Y {) z* S& V}" G- ^: x; x7 Q O: T; ]9 K
& m# W# r, R! }6 h) Z- J0 l ~
static void __exit led_platform_exit(void)
! T$ o6 c# D& B* H/ F7 n( i4 e{
& H' B3 G. P& ~* D* s0 h platform_device_unregister(&da850_evm_tl_leds_device);$ I5 f$ C* u* C, b3 T
K! z* L3 U [
printk(KERN_INFO "LED unregister!\n");: N' |) f9 e) [, [; E
}% C( g" d1 [3 I u( S* V, T
3 R6 @! z8 d) i, W
module_init(led_platform_init);
7 S0 T% F; a( E' H$ _module_exit(led_platform_exit);
+ P. t* f* T6 W1 ]
! z3 ^1 q$ M1 D2 u, iMODULE_DESCRIPTION("Led platform driver");
( A3 ~% D: v: S: |& D9 ?MODULE_AUTHOR("Tronlong");
* T( o' A9 o0 k7 jMODULE_LICENSE("GPL");
1 t8 m4 ?) u" E3 L$ ]8 s1 W) o! I; f2 @! s1 T5 y' `3 w! h
|
|