|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# m& L5 O, a6 }; T0 a8 B#include <linux/init.h>7 t! z8 V* Y& D2 y9 ^
#include <linux/module.h>
4 A# Z9 r) X" V H2 I#include <linux/kernel.h>+ y) ^! l& s) ]. @5 i
#include <linux/types.h>
J/ |- J5 S* \! N* h; d#include <linux/gpio.h>5 C# P& h, x( c5 s. @0 M
#include <linux/leds.h>
, M# ~4 S6 v, B#include <linux/platform_device.h>$ c7 J+ _% Q2 w4 I+ c$ H- Q. s
! q0 |0 E0 l" a$ ^# M#include <asm/mach-types.h>
2 I. a: o4 }: h( F# @) a#include <asm/mach/arch.h>! ~9 Z5 y& T s! H. c0 G
#include <mach/da8xx.h>, d: H2 p5 w; \ ~& T, @( h/ R! S
#include <mach/mux.h>
% v9 c: z! d, M2 C
* P) h/ Q+ Q" I0 u% u$ D5 I _* k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); y. u1 v0 ?# ^* Y0 o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" Z; o( |9 H3 t) }% [; ], v: Q! M- n6 {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 T C* `8 N! O8 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( ]9 `- Q6 H4 k1 \" V' I
! z" p; B9 F/ F$ q7 c
/* assign the tl som board LED-GPIOs*/4 C' N3 N: ]7 C" e
static const short da850_evm_tl_user_led_pins[] = {3 ~& S t) {; K* G# Z! t
/* These pins are definition at <mach/mux.h> file */" q( d& {# Y1 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, Z ?, Z8 B' H" p/ d: G
-16 ]7 s# t B7 d4 |& O. c4 `, k3 J
};
' b# \" m$ X( O7 G
: ~7 w j; M: Q( K2 b8 q5 Cstatic struct gpio_led da850_evm_tl_leds[] = {7 f! a c1 K8 Y2 U/ N7 n1 A
{
- `4 S* {1 H; j( p .active_low = 0,
; _5 M' e1 g" t6 d$ p2 K) k5 V .gpio = DA850_USER_LED0,
# q( T( w: P0 o8 k$ b: |+ g2 p .name = "user_led0",! z: |' {9 Q( v0 Z
.default_trigger = "default-on",) d+ K0 V/ o- E: ]' K% h
},4 p, R: N3 I- g
{$ e2 ~, L4 ~7 v! N6 J" u. K; \
.active_low = 0,2 n$ P3 f9 |" ?# f4 T: N% g( O2 J
.gpio = DA850_USER_LED1,
, _% J$ W. ?6 l `, e# {9 h9 X .name = "user_led1"," ?- p; I3 z- r) w" e7 d3 u
.default_trigger = "default-on",6 j4 ~* T, C! ^
},7 [% g' ]: ^7 D2 ]# C' g
{
1 \" Y$ O/ u) ^7 z$ B, w .active_low = 0,, y1 C' |: o( ~
.gpio = DA850_USER_LED2,
' L5 u/ ~6 p6 y6 i. D7 _0 G .name = "user_led2",
7 s' t) k2 d* B- o+ j3 e .default_trigger = "default-on",) F. f0 Z1 l; d2 ~' B) N8 l
},
; i. g% Y$ F5 [8 l& b. V {5 y( \$ [# u' w5 b" {7 a( f. d, ~3 {
.active_low = 0,
- o9 [6 K, A m# X$ E .gpio = DA850_USER_LED3,
, s& r' P1 A: _* y6 B7 \1 Z$ T3 I .name = "user_led3",& `4 k9 e& K- l: S7 l" l
.default_trigger = "default-on",
i4 f7 e. v1 H9 W4 q8 W },5 ^% \( D7 m$ t% _7 W) x
};
6 r( ]/ ~( ^ x" f$ Y$ V$ s4 a1 g- h* H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 a. C3 M2 b" V8 q+ a. v .leds = da850_evm_tl_leds,# X, h1 Y8 ~ w- ~, J+ e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," b( A/ n$ M1 O+ P+ ]3 c
};
6 z$ V+ ~9 ~/ B. H$ u: h! z# O! A; z% M0 p
static void led_dev_release(struct device *dev)
# l: h% p- C2 l6 m# g{9 d+ v) H2 e$ w
};
5 k6 F& a6 L+ d- B9 H1 C- C
2 O c& U4 @' Z# a8 W: zstatic struct platform_device da850_evm_tl_leds_device = {$ }0 J8 H6 `- j. x' `& R
.name = "leds-gpio",/ H5 z) ]" F. y* h: n3 n
.id = 1,
9 X8 o+ }$ }# q+ k4 r# G" C .dev = {, Y4 C0 F+ T7 R' N6 b
.platform_data = &da850_evm_tl_leds_pdata,' W2 j7 i8 s" K0 i z5 o
.release = led_dev_release,: n5 S/ |. _" c: y0 A9 ^% E$ \" J* l
}
2 U4 t/ h2 B/ s: o9 b};
) e1 B8 {; c' ^/ t: Q' L6 y7 k
# `* d; M( I v' A( `+ g8 ?* qstatic int __init led_platform_init(void)
: Q! A) m3 @( s) F4 [{
. k3 n3 u4 j$ q. S, j int ret;( t* r" X) j* V
#if 0
4 |& R9 @4 [( ]3 T# p/ P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 _$ z: H" S \4 I+ t* X if (ret): Z3 o9 V! e3 V# s; s) C! H' ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 i5 F! ^; W# W, [1 G1 d) c# n
"%d\n", ret);
1 L# r5 e1 B8 B; G#endif
% w8 r. V$ g- c! L ret = platform_device_register(&da850_evm_tl_leds_device);
1 Q1 s. `! a4 L) A' N* J if (ret)
+ {/ o7 P8 Z: p5 N' P( L$ ~ pr_warning("Could not register som GPIO expander LEDS");
8 c# ~: ~4 M" p- e# i" [; B& x else D/ t( U+ w' S; j' \
printk(KERN_INFO "LED register sucessful!\n");) t6 Z5 W5 h% v+ s
8 e+ M9 l% w/ y" b* r6 ?' Q
return ret;
$ {' g6 t$ s6 U) g}' \1 P+ p0 r3 s$ a O! `9 I- v
9 N3 M7 o$ C% |* o' D+ R$ kstatic void __exit led_platform_exit(void)5 ~9 p6 l. d% _* a' G9 Y; ~
{, a" C, D {1 b! g" D
platform_device_unregister(&da850_evm_tl_leds_device);
5 S ~7 i6 o' R/ X$ Q& A+ n( v y& c
printk(KERN_INFO "LED unregister!\n");
/ ?, \$ ?/ F6 z3 V% z# B7 G* v}
3 P" k( N$ l8 `2 E& a5 a4 Y6 {+ l* g) q3 Z7 J
module_init(led_platform_init);
- s+ d; s# h- P( M3 b! Bmodule_exit(led_platform_exit);! i, z; k; ^" R4 z
. h' A: h, d* _9 vMODULE_DESCRIPTION("Led platform driver");
' O& `: [6 y @; U+ y5 y2 j" ]7 iMODULE_AUTHOR("Tronlong");: V5 ~( z8 c6 m" F/ |
MODULE_LICENSE("GPL");! r* M# P" ^2 A2 L
8 y5 a, L e+ y, y |
|