|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% U+ v0 {9 t0 N6 i J$ n9 V
#include <linux/init.h># \, w0 Y/ c& F9 P- e8 }
#include <linux/module.h>9 v2 j6 i# N d }% Z3 y' }
#include <linux/kernel.h>
& U+ |3 g/ o/ l) s+ M$ `0 i9 }#include <linux/types.h>; b8 y9 e' [0 I
#include <linux/gpio.h>1 b' X3 B7 Q7 Z" p! W4 M8 C
#include <linux/leds.h>( b: t% ]7 c7 L, z* c2 f/ q" }
#include <linux/platform_device.h>
G7 l; N9 h; V+ m! s# k# m/ q
- E/ E/ @) g6 w0 K: u8 ^( Q#include <asm/mach-types.h>
+ Z f6 o2 m- B- v+ \#include <asm/mach/arch.h>1 Q8 o9 r3 x/ B9 e5 L% p
#include <mach/da8xx.h>
) t: M3 ^& Y0 h+ e! W#include <mach/mux.h>
* d; s- a* ] L/ B- {* j9 V* K. E# Z' m& p9 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ v0 i& J* `9 [/ y3 r. S! S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# v, O2 f1 h1 k, A7 l( D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 i& ?7 b s( v7 C# @% J# C! K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 t# m: f X& o0 t7 z: ?8 U5 N; v+ z$ c2 k9 w- }1 y, u2 B R
/* assign the tl som board LED-GPIOs*/2 I3 V' {* h$ L9 H2 p8 _ Y: [
static const short da850_evm_tl_user_led_pins[] = {
- O" {# p9 A) k /* These pins are definition at <mach/mux.h> file */, _( \/ B, F" f# A$ D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 d+ o3 K6 ]( f; ~ -1: s) @8 ]- |) W9 J9 r. e% s Z: T
};
/ u* _/ W) C2 p& {# K- z& X+ s) D: \! Y
static struct gpio_led da850_evm_tl_leds[] = {1 d: p! D5 {, m3 ~( N( S A
{
0 A {4 ^* m: l) F2 y. ]. f .active_low = 0,
% E, f, Z. A* A. ~; N3 \5 m/ N& c .gpio = DA850_USER_LED0,
+ T Y0 n5 u8 R' j .name = "user_led0",5 M( }) E) p7 g% O1 b% o5 p1 {
.default_trigger = "default-on",
3 u t8 V$ v! V) ~3 ~ },7 r3 O D8 e- I# a y- r+ [& a
{
- v4 p4 j5 Z! {7 f. T0 y* Y .active_low = 0,+ u. h. B! l1 {% R& B v* r
.gpio = DA850_USER_LED1,
: k" N. l; k2 J* v! S" U .name = "user_led1",
6 P- d5 s( V8 f .default_trigger = "default-on",2 a) s# v; V& ?4 S0 C% ~) ]% D; d) e
}, h: z7 c9 E, V6 r, J9 D1 X& s# i
{+ ]+ W) p. @8 c* u9 H- |
.active_low = 0,- z: a' O- y5 g/ z, R5 l+ y% y; H* M* ?
.gpio = DA850_USER_LED2,# L# X% v/ Q: _0 c) r( o
.name = "user_led2",$ v5 s% C/ ?% j0 z4 m% T- _
.default_trigger = "default-on",
5 o* h0 }1 v, j# v9 i( C },
2 i+ g/ Z7 v5 t1 o/ D, S {
) d; N S9 l; X3 J/ t. p! I( K* x& W .active_low = 0,
6 P9 ?3 V5 @6 p .gpio = DA850_USER_LED3,3 @4 {) o& {0 s: n
.name = "user_led3",
- o: l8 Y# O; e' w* m, d4 F .default_trigger = "default-on",
# M' N6 n6 g( D0 q7 i },
- R# z+ V& P1 J. U: S};$ \- l4 \8 _" M
0 o+ a: K3 _) j1 w/ L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) e9 s7 h2 n5 r .leds = da850_evm_tl_leds,0 W! [& L6 {1 k% e% r. k& `+ U& [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* x5 l: k: }3 Q9 \4 G1 s};2 @' ^/ a1 X# ?! }& g* K1 g/ [8 K
3 |) X5 f, n, R
static void led_dev_release(struct device *dev)
- i1 x" ?. {- @5 U$ Q) D{+ Q( }) x& S# D8 y8 H% g1 w% n
};' H. O& m0 A+ j( S; d! t; o
- ^( {5 {( h; a5 p* {, bstatic struct platform_device da850_evm_tl_leds_device = {) Y+ w& d5 }) F/ L: \6 X
.name = "leds-gpio", V/ k" Z$ S* L% J* P8 N
.id = 1," `& e$ A- S7 Z+ S" l" T
.dev = {- ]. _) T; r# H/ N3 a
.platform_data = &da850_evm_tl_leds_pdata,/ @- } A* d7 ^- X/ Y* s( w
.release = led_dev_release,
1 h* E8 a. B& X }! Q7 S3 V( @$ Z5 R1 B( q1 L- [! C% P
};; \( h3 e6 n2 {; o
, O& q% i$ `. i7 E) |
static int __init led_platform_init(void)
4 i7 x }+ m5 }) N{
( [& Q; K1 q" u3 W! T7 ?0 \. c5 ] int ret;
4 h7 D. F# R3 t9 k( k* `' i# i# f; j#if 0
& q$ k0 `. o @2 R/ v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; K0 W# F- u* [4 N if (ret)
4 b; b2 g6 ]# X7 ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- e/ r6 x1 D1 D7 e4 m0 \+ J
"%d\n", ret);+ _/ V5 k0 R# @& R
#endif% [2 u- P0 ~5 n( f( F
ret = platform_device_register(&da850_evm_tl_leds_device);$ q: e2 g- _6 W4 f! p/ [
if (ret): I# ]# G/ q+ U/ r
pr_warning("Could not register som GPIO expander LEDS");
, s, [$ C3 }! }( k8 Y else
" K7 @; Y. n6 L4 t, U printk(KERN_INFO "LED register sucessful!\n");
$ d! i H# m0 i# F% P* G
( B, M! z W6 W: `; Q9 H return ret;4 }3 W9 Y g! R$ B2 b% Y P
}. u# h/ k1 x1 l% _" n4 ]& `
: U C( f/ Z V, j- Astatic void __exit led_platform_exit(void)
0 y: _% M- q# U6 }6 V% X{
( b- R% Y& b- `7 l: a; h4 v7 a" g- `, a platform_device_unregister(&da850_evm_tl_leds_device);
: _+ j) h% x: T1 V
7 i. P; Y* C# @+ A2 s printk(KERN_INFO "LED unregister!\n");
% k- {4 y3 y! i5 Y! Q) \}
2 P! c+ X) x0 J: X
$ o0 E5 r" h9 w; [; C* dmodule_init(led_platform_init);
/ g$ }: b2 b+ K, g# {4 G0 Jmodule_exit(led_platform_exit);
/ V2 O H$ J9 j; {" l% @" R4 z& |% }9 g. L
MODULE_DESCRIPTION("Led platform driver");2 U( e& f. L Q6 O4 |" c
MODULE_AUTHOR("Tronlong");
5 z! i- q! z& X8 [$ ZMODULE_LICENSE("GPL");4 ?6 [$ f# q; G, y9 k e
5 u* M n# x8 b) \ |
|