|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& M, L5 C" Q3 [' i6 {#include <linux/init.h>
% x5 s) G* I4 Q ]#include <linux/module.h>( @9 q' `/ |) h; {, ]
#include <linux/kernel.h>
% \! F, S/ p$ t" p( o2 R. B#include <linux/types.h>
& g" \+ ^3 p) U3 t' w# `#include <linux/gpio.h>: \, F+ W2 c3 @/ L
#include <linux/leds.h>+ ~9 v" G! f" [1 C3 `7 W* k
#include <linux/platform_device.h>* _4 M; K0 e! J5 c
7 \9 q" O, {- t0 c$ d% @# [
#include <asm/mach-types.h>
- ?: t; X) ~- W- S8 S#include <asm/mach/arch.h>
% }* {3 \" o6 h( @#include <mach/da8xx.h>% J0 x5 m7 A* ~9 w1 J
#include <mach/mux.h>
! ^, M- |- ?8 {/ M3 x
}, r' V7 H7 E {! ~. q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 f4 c$ N/ j J/ C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 V: }& i+ @8 j7 L y4 X* y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ X8 Q8 V& d S6 d( E) w7 z4 R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% ~" r8 ]! n5 |" C- J g
4 x& b' f- v1 e6 P* p8 o/* assign the tl som board LED-GPIOs*/, d3 f- N. f% [' J: T# j
static const short da850_evm_tl_user_led_pins[] = {
+ [% Y$ D* l) t( ]. w /* These pins are definition at <mach/mux.h> file */* Q* ~: A2 f6 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 b5 q# E5 j2 [% j0 k
-1
: t- x, |" k4 e, H* b$ ~- s};
- S |, A+ V4 e) G" C# p
. q; f2 V' M4 D8 c6 e' ostatic struct gpio_led da850_evm_tl_leds[] = {
* O- V% q5 K$ l3 w {
5 `2 C& ?# `. } .active_low = 0,
5 h8 e+ {3 z' y, [; G% k/ @ .gpio = DA850_USER_LED0,
; |6 g+ G b" ?* [4 [8 v .name = "user_led0",3 R* ~5 B' ], P F9 t1 V8 f5 t
.default_trigger = "default-on",
; X% B( }/ g9 u. e6 x },
, z6 w9 Y% |( S, {: c {
9 {3 F. e4 ~- X; K .active_low = 0,) g6 }, o e, N4 M) p- M
.gpio = DA850_USER_LED1,
8 z' X& _6 r3 Z .name = "user_led1",
. @8 j( I1 E9 K) e1 }* Z .default_trigger = "default-on",
8 s% t+ q( G8 }( v- n$ |9 J; p },
4 ?* }$ S5 p7 u9 H& w+ }2 z/ [ {
7 r2 u- ^& i9 W. {' [ e .active_low = 0,: D0 g- x2 A+ z& i
.gpio = DA850_USER_LED2,. x0 K7 u( a2 n/ i
.name = "user_led2",1 o- T6 Z8 G, @
.default_trigger = "default-on",7 G0 ?, `" V* v2 X
},. Y. Y5 W% |0 a# i4 A! c, t
{+ W; ?# \8 K$ x. a" C
.active_low = 0,6 J' x& z0 L" ?1 U7 T
.gpio = DA850_USER_LED3,
+ b% q, M" L0 `0 c* V, ^ .name = "user_led3",) q& [& `! |5 m* i/ r
.default_trigger = "default-on",
$ e8 M% P9 ~! [ r% I },' E& r% X5 D- \0 N d
};
( A. C" O% v8 D4 Z! x' {) Y* n9 ~0 T$ e4 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 o- e' v0 e+ n9 U9 K S3 O- ^
.leds = da850_evm_tl_leds,2 ]4 S% p: ]7 A2 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- D7 S% |- D0 m};3 J2 h5 Q' V: f! f- z& Z X" y
7 k3 x% _2 r) m! h, q3 O/ d6 Q# jstatic void led_dev_release(struct device *dev)
" }* a4 w/ f5 h" A+ `{
/ V9 B1 }, Z5 D( W/ T% ?};0 R/ o' N s/ P# g. b9 o& l
4 z- v4 O* e, G0 W8 N" U/ p7 Xstatic struct platform_device da850_evm_tl_leds_device = {& O$ \5 Q# E% X x% d& S- o Z
.name = "leds-gpio",& y0 k; y8 v4 g! u+ h! j
.id = 1,4 w; t4 m2 v0 T; N- ^# a% R* `
.dev = {# \+ t. i* q! p& g
.platform_data = &da850_evm_tl_leds_pdata,
) J( Q* ?" D# j9 w6 L4 I8 h0 X .release = led_dev_release,
8 N% v8 I' `3 M9 e2 A+ m7 B }
" K6 s# m" M! F; a% U}; w, Z( W( ^- I. k2 x. a0 t. P
. ^+ D9 E! L, t) t! T1 n" K5 [( ^
static int __init led_platform_init(void)1 k8 e# z& R1 J# y8 Y
{: H1 j0 `( E# A) V+ D
int ret;
. a2 n# i: q* C r" z$ X: g. A#if 0 \8 E( l, |% u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ~7 D* h0 }: ]% F W if (ret)
: T, |- K* H( I' X; N. O9 q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 }' S: y7 L! h, l4 E "%d\n", ret);
* m9 d& j6 }0 w& W5 @#endif9 q' J; `7 v G6 C* B. g) b4 [9 [
ret = platform_device_register(&da850_evm_tl_leds_device);2 H, _4 f; A8 r8 V
if (ret)6 \: H5 a% H* M" i; z# _
pr_warning("Could not register som GPIO expander LEDS");, i) e. O; o% c \- c& u: Q
else
' M: M( f# M* J+ F2 t r printk(KERN_INFO "LED register sucessful!\n");; j1 r5 e* O* m9 c3 |. w
, m, P3 @; b! K3 v) v' H* ]( I return ret;1 I& J# g. Y6 r _7 d
}
6 C) L, J8 `7 P0 m' y- H/ j& S
static void __exit led_platform_exit(void)" U% q6 u: L9 Z
{- L* G' W3 U( I7 f! e
platform_device_unregister(&da850_evm_tl_leds_device);9 x. X" `) r% D/ ]3 N7 l# ]
5 w/ a8 ]6 R9 z6 q9 p* \ printk(KERN_INFO "LED unregister!\n");
- x! J8 M3 Q+ }' P, l}
4 G: V& s" _- T) q. K! n2 Y2 B* I, @9 r* a" f8 `; y. d
module_init(led_platform_init); p; k; l4 s% v
module_exit(led_platform_exit);0 \6 q* L5 B* b+ q" J! h* V% {
6 }) H) k+ s/ @0 \1 h
MODULE_DESCRIPTION("Led platform driver");9 e4 b7 l2 k% T# B+ C
MODULE_AUTHOR("Tronlong");
5 {! `4 X/ \' H# k d% _8 s9 XMODULE_LICENSE("GPL");, y ]* i+ ]# [/ F7 K
& `' W) `" P* z& R% e' J
|
|