|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ X& ?0 S0 V# N; l( K
#include <linux/init.h>9 n' p- ~& b4 ^2 X5 W( r
#include <linux/module.h>
2 T' S, B4 ^% N# f2 V# Z" b#include <linux/kernel.h>
, H" O2 _ y% ~5 T/ S#include <linux/types.h>; Y% g8 T5 J( z/ A
#include <linux/gpio.h>
3 r$ D* C( ~& H2 F6 N#include <linux/leds.h>
& N- l. b! ?2 ?: ^# h2 E! t#include <linux/platform_device.h>
9 I/ s8 a- u) p( E
5 P# {) }) ~7 T, o#include <asm/mach-types.h>
8 Y3 g6 V" p* S7 C+ I( j#include <asm/mach/arch.h>
% o# N" f* I6 W7 a7 n+ g" f#include <mach/da8xx.h>
' C2 w4 Z( i& _- s; W/ U#include <mach/mux.h>& f) {1 y: B; Y4 v4 B; i, _- M
$ Q# [6 V- _* [! |8 E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& C, L6 @& K5 H) l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- }3 \: v4 Q7 ` O3 s- C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# k) w: G# n5 @; l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 r4 I) w- z. O7 C7 O Z ?8 m6 h9 q" ?) }2 E2 D
/* assign the tl som board LED-GPIOs*/
, w( v' i b- l* y( N# wstatic const short da850_evm_tl_user_led_pins[] = {" ~; ~6 n, P/ u7 G/ w0 V
/* These pins are definition at <mach/mux.h> file */
h7 }0 N* c" u0 Q3 K! l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! d8 B8 s! O7 G+ C8 N
-14 }( L2 g9 \1 K' X
};
; z' X7 P" M- Z: b" g, { q7 K! M3 m D* e8 X& E; J5 n
static struct gpio_led da850_evm_tl_leds[] = {4 f7 l* J, T8 [( I' R
{
( }: e1 g: A8 p& Y+ ]& N9 N/ y .active_low = 0,
4 {7 y+ h3 g/ `4 \$ I7 ^- V .gpio = DA850_USER_LED0,- F% D$ e9 a' l* L
.name = "user_led0",
; p4 ]3 \5 D# @ .default_trigger = "default-on",( {! a" M$ `& z7 \2 e/ G$ W0 M
},
9 w! K7 J6 O! g {
$ \( X) |; x3 y. ^ .active_low = 0,
+ [* l5 y: n& E; t8 ^8 Y, I/ ~ .gpio = DA850_USER_LED1,3 G! z) g2 c1 O V9 q
.name = "user_led1",
6 R% r+ @. N- ] .default_trigger = "default-on",
% u$ ]2 O+ N- t9 q },
: |( z/ z2 t$ \$ X/ ~+ n' w% f {& I+ P% k$ ~- I
.active_low = 0,- c* Y" ~5 g5 l5 j$ n# m
.gpio = DA850_USER_LED2,) {( X7 R+ W1 u& d. C& G
.name = "user_led2",* Z7 n* {' M& Q+ c z5 D
.default_trigger = "default-on",/ ]# a: ]/ x5 b: P- Y- K1 Z3 V
},
3 m" R( ]% {1 q4 X {, A' [2 { r9 x2 [5 X; M0 H
.active_low = 0,
- w: k5 H3 A, f& [8 `! e6 | .gpio = DA850_USER_LED3, N( y* z) @) H
.name = "user_led3",
# I0 z! k8 l- {3 A .default_trigger = "default-on",
3 V5 S1 w' D; U4 u! ~! t },; e+ ~& g' v6 M! a
};
+ A3 M( y0 X5 R8 D) x" M9 }- [
# ?3 z1 G2 I) ?& k' r9 \. ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: K2 s! |" m7 x, \! a$ o8 M- e
.leds = da850_evm_tl_leds,6 U& X& s! J( O; W7 l0 P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. k( Q9 y. ?; A2 D* R; b+ T7 F};
' Q/ z9 \, P0 M ?6 @9 E! x3 x& j( l* ]( D9 k8 f5 P# O( M. G
static void led_dev_release(struct device *dev)3 i: _9 _: u; u8 T* f' M% x
{
l1 m% P0 f7 Q$ \" K}; y6 S7 ~" @3 O2 @& A- M
4 L' ]* O/ r! ^- h* B% t# I; p& U* t- P
static struct platform_device da850_evm_tl_leds_device = {1 v. ^8 Q o% ^3 _0 G
.name = "leds-gpio",7 Y) ~3 K7 m3 E2 k
.id = 1,
6 G3 b2 r3 u5 ? .dev = {
4 y @6 y; x+ D1 j9 Y8 P+ q .platform_data = &da850_evm_tl_leds_pdata,
& k' r4 B2 h0 w/ ` .release = led_dev_release,
" a$ U9 ?' q6 E# m; v+ M }
9 t: ^6 J: B! \6 Y5 R2 n+ a};
! V4 {2 S) L' U: F( }& K
) M3 S: e4 `0 C' v- t5 [1 Rstatic int __init led_platform_init(void) m( [9 N% E9 x4 C. o3 E
{
. G+ @" V+ H; ~) t2 l int ret;. m. l, t* A; F7 ~' g; J
#if 0
5 V& p3 u! Z5 f7 _. ~6 ]9 i! U4 { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' `- o$ l7 G( R& d/ B, y if (ret)9 Y: d0 ~1 Q& ^; u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 Q% f! s0 @5 T0 }1 ]) p
"%d\n", ret);9 _1 I4 @" O; Q" J- @, H* \. I
#endif
) i' S" x3 f& C) j8 B1 V- n ret = platform_device_register(&da850_evm_tl_leds_device);
) f5 i3 N5 T# n& p& P) h if (ret)
9 r+ q X% f# m: S( } pr_warning("Could not register som GPIO expander LEDS");9 g2 G1 h2 I7 ^# f; ~3 r# d0 l9 Q
else
7 C0 q4 J% G1 I2 p9 N) K0 A( D printk(KERN_INFO "LED register sucessful!\n");8 R% T7 q- X# q5 ?
9 |- \7 Y2 r! W0 P: C5 Z return ret;; q, g4 d+ r) ~: }9 S O
}
: T3 |4 j! D( F& \4 @/ ?, Y/ ]( E! x- W
static void __exit led_platform_exit(void)% k2 }% f0 q4 x3 i: C
{
+ e) f, Q, h, m$ F6 o" k- R platform_device_unregister(&da850_evm_tl_leds_device);
' r8 e+ ? H4 U7 L5 Z# \- f3 e. k+ T1 u
printk(KERN_INFO "LED unregister!\n");
% x3 ]7 \$ j o' `1 j}' P9 V8 l3 ]- C) h! T/ H z: g
7 _" Y: P* [. n1 { M
module_init(led_platform_init);
) a+ J) p6 d0 @: O. r6 t+ K7 smodule_exit(led_platform_exit);
8 F% |9 q1 f& O& ^. _
# u0 w& U; W. K" J TMODULE_DESCRIPTION("Led platform driver");2 f- A+ F/ j, p/ Z/ q$ m' S5 `
MODULE_AUTHOR("Tronlong");) g/ ~/ _4 y4 |' W5 M
MODULE_LICENSE("GPL");5 q# E T+ Z. }3 r, U2 u
; C- x) L- }, l; ?( v. R |
|