|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( K# [! M0 |/ C3 }" u$ ~8 q#include <linux/init.h>0 B% {$ f+ y7 O8 _ V% _
#include <linux/module.h>" P) k" m4 G! a6 I
#include <linux/kernel.h>( g7 N5 e% C0 F: [/ u: d9 a
#include <linux/types.h>
# d o8 Y" k* a#include <linux/gpio.h>: k: u' V3 i4 ~* Z3 b
#include <linux/leds.h>% `& [0 r9 K& P6 c
#include <linux/platform_device.h>
; x+ S4 G7 Z+ f6 d# W- A+ Y, n) O# f
& n5 d5 F2 I! i* z! H#include <asm/mach-types.h>
# w: t! j. \& F0 @3 `" i" v#include <asm/mach/arch.h>8 q0 ]5 s) k8 D! L" k2 ? S
#include <mach/da8xx.h>
0 j) y7 J, D0 u& D1 D* l% h# K#include <mach/mux.h>
* m! A$ p8 m$ x5 n3 b/ N8 e/ P) j( \( I0 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" ]& A. y1 [ E% w5 [ d! r
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 _4 ? L: ]# K5 b: @; g6 @$ r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ o5 p; H) Q @# P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" {6 W$ C9 n ]! B3 S
0 Y$ z8 @6 M l6 ^4 F; O+ W5 h; p/* assign the tl som board LED-GPIOs*/
) e: H. m0 L$ |# j- hstatic const short da850_evm_tl_user_led_pins[] = {4 X( G( f, n4 P6 ?! x, I
/* These pins are definition at <mach/mux.h> file */: v i: l- i5 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 i. k6 f$ F( r
-1
% {4 z9 g6 G# z/ x: p1 O};! A. D( v4 G& x4 g7 T4 u
! s$ V+ V8 H) r p. z
static struct gpio_led da850_evm_tl_leds[] = {
3 Q6 R: N( U! }1 u; a8 Z! K {
2 l+ P- \' @4 Z9 ~ .active_low = 0,# ?0 L8 B5 t- _6 s, Y2 d: R, ]+ ]/ J
.gpio = DA850_USER_LED0,. h$ k9 u+ W$ V/ Y$ j
.name = "user_led0",
+ J: |4 ~* E! ^ t$ _8 u! L! d .default_trigger = "default-on",
( [5 L( m- }9 O# a3 ]4 U },6 R S, l) U/ s' x* C" r7 v
{
! O5 e2 K& \' [# ]% O .active_low = 0,2 x3 ~/ K9 z- a; Q0 R( ?9 }
.gpio = DA850_USER_LED1,
! m4 C* X. T( l" j& d# S# Y .name = "user_led1",
( b" o A/ t4 Z2 R2 G9 k; ]# F .default_trigger = "default-on",
- ?# f0 g: g/ I- Z3 U2 X* O d },
1 n0 V: M- Z# M3 z( `2 [ {+ c& o& r) x+ v: ?
.active_low = 0,
: ?) w: I1 @0 A9 m+ ^ .gpio = DA850_USER_LED2,
( X0 Z6 N. C3 X0 g! \- o4 i .name = "user_led2",* Z. c. Y& h/ j' r+ E$ \4 k
.default_trigger = "default-on",
8 t8 e: y/ [9 V0 m6 w" e },
5 K! r) ~# j9 K8 _ {
& D- I+ x/ I3 g. l .active_low = 0,
0 j u, Y, w: E5 | .gpio = DA850_USER_LED3,' y7 v* ?- X$ y! P& J
.name = "user_led3",
1 y! P9 D2 k3 `+ H" ?" i% N& t .default_trigger = "default-on",
0 S+ A' ]" G* r; u+ J },8 x2 P7 Q9 Y) |* X w
};
0 e0 V7 R5 m0 I# D- h# T7 u
1 b) w( U! o6 z' L7 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. [: S% m) M: T% c2 ~% b; H% b# }
.leds = da850_evm_tl_leds,
9 F v" J' [8 v- i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 C6 X% d7 w0 B
};
' H- _- K+ P S& R ]4 g& E4 B+ x: _- w) C+ `
static void led_dev_release(struct device *dev)
! y9 g: ^) e% R{
d' X6 y; E0 h7 i& u};
7 }1 Z0 M! y9 G6 y2 a. W
; C: Z+ G5 h( d0 ?) }- kstatic struct platform_device da850_evm_tl_leds_device = {( L. T, B, m; |3 |$ W: Z9 }
.name = "leds-gpio",6 s2 ?! z" ]$ X$ K+ T; Y
.id = 1,; j6 E+ n$ G1 R6 t1 [2 c! O
.dev = {
, i1 ]- N, c, z# M/ d .platform_data = &da850_evm_tl_leds_pdata,
, W, `1 c5 t/ v. j+ V+ b$ C' V .release = led_dev_release,
4 R! Z& x" F' c- ^3 M* ? }
+ N! @ E3 X) ^; _3 ^};
: Q+ x9 S5 U4 E# m
z1 ?% ]: H" bstatic int __init led_platform_init(void)
! ?% X6 k, z. N' |# C- i7 _{
3 q" q7 M t6 Q& Z6 W: ?: [ int ret;
# y0 l5 }8 h* T2 r0 F#if 0
) Y) Y7 N0 z" w. ?# K, W5 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' g0 E3 A+ B* h& M
if (ret). g! K! X& m: P) r$ X4 j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 P5 P& h3 N3 E- k1 |- [ "%d\n", ret);
4 r& Y' J9 ]% U+ m3 ~! F& v#endif8 `6 ]5 v' b( \
ret = platform_device_register(&da850_evm_tl_leds_device);1 m2 c0 ]/ h E: m# w
if (ret)$ d7 K w- t t5 p4 k+ X" Y0 \, X
pr_warning("Could not register som GPIO expander LEDS");- o# i/ {& Y( F; |7 p+ S
else
- ^, D$ B0 _6 x) x printk(KERN_INFO "LED register sucessful!\n");7 l1 b5 r4 z# N5 k
9 `( d9 ]. [; x7 f3 T T
return ret;8 t r0 w q2 y' y {! @7 w7 J
}8 |" n6 A0 J+ M& F
& Q' f/ E8 n- V* F) Dstatic void __exit led_platform_exit(void)* |+ l0 F1 d9 p/ H. k
{
0 z6 t: b* C4 A# [ platform_device_unregister(&da850_evm_tl_leds_device);+ q* S+ j) U- D3 U1 ?1 l% ^' _
4 D- E4 _: Z) S8 V1 t printk(KERN_INFO "LED unregister!\n");( N. a" R8 f' _) B
}% m) b7 G% _" M- g: |
, J$ v0 V5 ?7 L7 @$ d) {module_init(led_platform_init);
" z) m5 e6 l4 @- @; b/ Pmodule_exit(led_platform_exit);( J' {$ g- l6 V/ q, d
X) W! h W" {5 aMODULE_DESCRIPTION("Led platform driver");
3 W- y$ e; C! s* v9 RMODULE_AUTHOR("Tronlong");/ D# ]5 M6 U5 G- `! O
MODULE_LICENSE("GPL");
" r- R0 a( j, N% R2 p" h
; i" x2 k) N4 C8 Y- d4 y |
|