|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; N" m( H% u7 @) h$ H% w! A1 I
#include <linux/init.h>
1 v3 M( q) [5 b# Q6 \5 S#include <linux/module.h>
& |2 w. C- j2 n2 C1 W+ f( h* `#include <linux/kernel.h>3 a+ G9 Y6 C) Z' w
#include <linux/types.h>
7 y' O$ K3 z; m( `* t0 V i#include <linux/gpio.h>5 e& z1 C1 L$ s
#include <linux/leds.h>2 v* Q' o9 b5 A% P0 T. _
#include <linux/platform_device.h>- [, J: d; c l6 ?+ a5 V. D' R
; y4 Z L- _' w#include <asm/mach-types.h>
: r2 W% Y3 O' C, F4 F9 k$ d# V#include <asm/mach/arch.h>" V: Y' l( e9 K! h, p8 Q) H# H& z
#include <mach/da8xx.h>
3 O& Z+ k0 r: U. T4 f! r; O0 q#include <mach/mux.h>, n0 T( o+ t2 J z) }8 @/ U
' d; [8 t" n/ j4 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' ?8 A* J' _+ b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ x$ p8 x3 p0 B w+ k1 L" [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 ]' q" p4 y: _- E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 c! a/ P+ w5 m1 A$ B
0 H/ m# s) n# `
/* assign the tl som board LED-GPIOs*/. c1 {" ]1 C/ M3 d8 M
static const short da850_evm_tl_user_led_pins[] = {
9 r7 f! [# ]7 l( f/ J /* These pins are definition at <mach/mux.h> file */) g# H) Q% b8 S6 Q; a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ ~/ e6 D, g3 U) Y* P. _
-1+ W: a4 i, o) ^% a6 W9 s) F
};" [. K, Y& a: T& A- w
% @: T' J3 ^" D, e4 Y
static struct gpio_led da850_evm_tl_leds[] = {
% h% l% y$ b: E4 X {
$ h( w/ K* q4 [0 L6 c! u .active_low = 0,
/ V# r. O! u& G; f$ Q .gpio = DA850_USER_LED0,
) f' a1 p6 G8 g .name = "user_led0",* z1 v3 k, Y. b1 E! r' l* e; `! C
.default_trigger = "default-on",+ x# ~5 m# ~4 G" m+ f/ J% ?% ^/ [) a5 p
},
6 {/ N% p) B4 C; y% c9 `" P9 _/ V {
& a4 d( V1 ? Y2 B9 s .active_low = 0,
# I3 j& x+ V4 ~$ W: ?! G .gpio = DA850_USER_LED1,
& o( I" S- j7 z U: ~4 T, |8 L .name = "user_led1",
7 c0 h1 k3 T& w- a) l3 m8 v .default_trigger = "default-on",$ `) m4 O4 J- w9 j
},& G& i3 w# o- I* F. Z. U0 T
{
8 ^0 M. f+ j9 k' c .active_low = 0,
3 A2 z" A9 G6 F/ {$ f .gpio = DA850_USER_LED2,
8 m7 g9 Z% v B- L6 _ .name = "user_led2",8 b: t R) N; f+ m+ j
.default_trigger = "default-on",8 m6 V9 `! w G5 d! G5 R2 ~ @7 V
},
5 ?$ Z& c* }9 G: a. n% D3 d7 ^6 a {
6 q* {& q+ a u; u+ b: l5 o( s- ~ .active_low = 0,! Q; |$ A- E; U/ e; `% U2 R6 E
.gpio = DA850_USER_LED3,# j, S* P8 v. m9 L
.name = "user_led3",
# _9 Q9 ^6 e- G; J3 d .default_trigger = "default-on",
& s! I8 ~: o" @ },( V: e8 P+ E# r7 i9 L: \' ~ X% J
};. s9 j2 P3 y9 \& I8 E: ?
/ n! A1 I' x; ~2 Q8 X" H3 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 @- g8 r+ \. A- ?/ w2 Z
.leds = da850_evm_tl_leds,
" w7 P) e. V% ~% U K4 m: @$ m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 \( i" O2 r; H
};+ h. M% R. `* g! X
9 G. M) Z6 W) \0 T
static void led_dev_release(struct device *dev)% f8 g( V9 a& a2 i! h
{
( D/ u$ i- q2 D( y( K};
7 f- y# z! L# ^7 h K) k
, M$ i4 k, a. I2 n) l, Hstatic struct platform_device da850_evm_tl_leds_device = {" o2 |: p7 O3 c: e2 h- d) K
.name = "leds-gpio",8 y- y9 ?- A9 u8 x3 f6 o; `3 o
.id = 1,5 M, g# c. J4 H$ Q
.dev = {% J0 R* ^2 M3 ]
.platform_data = &da850_evm_tl_leds_pdata,
& _3 ?7 A% z k: h .release = led_dev_release,
& D6 u x) u1 H8 L }7 V& `* `8 j# h S4 F p
};: t" i9 M* i" Z U# N8 V: b$ o
3 s9 d! Y* T+ sstatic int __init led_platform_init(void)% t4 z8 E8 K! C6 h
{0 t% X* s8 M5 b) A
int ret;
1 b% H: E# Y/ g# q#if 08 I2 n& ?3 `; t) S) P& }9 { G9 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* M: C4 w+ `! d6 e1 W% k if (ret)
! d; l4 ? X3 ` D* l: H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! Q7 X* j- n# u8 _# g
"%d\n", ret);
: Y1 I, w) k4 b% d#endif7 l6 T! C& a; r$ c" _
ret = platform_device_register(&da850_evm_tl_leds_device);
2 Z& p- Q" [! O3 X if (ret)1 k4 c1 O6 b( j, K, p9 b' A9 }
pr_warning("Could not register som GPIO expander LEDS");
v/ b6 p# S: Z$ g% C+ ` else
& P h2 ~ Y4 F4 ]' P4 |, {1 i printk(KERN_INFO "LED register sucessful!\n");. H3 \, N/ |2 R8 C' V/ X9 Q
4 H$ @$ B( G) Y! |) @
return ret;
( l! c! @) j1 V}
* l# T8 C \8 A' T R, w+ K- c* i: K
static void __exit led_platform_exit(void)2 y% Q$ D6 I/ S3 M$ C1 D% \7 ?: V0 X" r
{
9 P2 h! s( z9 L( i platform_device_unregister(&da850_evm_tl_leds_device);
7 G9 x3 p; r. K9 f- f% p0 C; W- k; i1 \
printk(KERN_INFO "LED unregister!\n");# o4 [; z8 B4 o3 }* S+ G
}! P% j$ k, \* s
, Y: s/ ]0 T- _) E. B0 r6 }2 r% o) }
module_init(led_platform_init);
7 B, v7 `9 \3 H1 e! A+ jmodule_exit(led_platform_exit);
. K8 p+ Q7 o" c$ c9 H/ E7 k
# i. l. K/ s+ DMODULE_DESCRIPTION("Led platform driver");
m/ ^" `9 ]3 g) P4 C2 ~4 gMODULE_AUTHOR("Tronlong");. `2 x; T7 ] V
MODULE_LICENSE("GPL");
' O6 p0 T+ a+ x6 g' D1 H6 \ r' R8 b, X
|
|