|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( Z) n1 \* |& q#include <linux/init.h>
0 y8 O, Z/ |' F5 ~#include <linux/module.h>
, c d v' r+ q- b& f( U; H9 B$ |#include <linux/kernel.h>
" Z2 E3 W* h* g; b( }* M#include <linux/types.h>$ y2 ^7 C. y$ T7 X: O8 W
#include <linux/gpio.h>
$ N4 R2 {! J7 o#include <linux/leds.h># b. k$ m9 K0 J% Y3 V1 ?. j
#include <linux/platform_device.h>; b; F# @6 G5 R8 r8 j1 K
: c& X. ]$ K% F9 C, T
#include <asm/mach-types.h>- \" d4 j- } u" g$ f, D" m1 c
#include <asm/mach/arch.h>! q# @$ H7 }- d& _ i w' F
#include <mach/da8xx.h>
3 m3 D- @8 C. o r' M#include <mach/mux.h>* |9 X# S4 K* ^) {; O! T: s
# q4 ]6 t: F5 u7 I" P7 o0 n0 E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 E1 d4 t+ n& @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' h! [( o9 |) f* _' }( ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ M I0 I3 X9 k X4 A' C" [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 Z. Z0 p/ O' {- y% J0 x/ N5 B/ q9 f( l( n# h& a* e
/* assign the tl som board LED-GPIOs*/
) ^+ _% n1 ^9 `: `' P4 astatic const short da850_evm_tl_user_led_pins[] = {8 \, D) b. w8 _9 A
/* These pins are definition at <mach/mux.h> file */" c1 a& l- j, h6 _* S/ A- U' h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& i: r7 ^9 {9 P3 ]+ Q/ Z
-1
+ ?) A* y* z W c9 n5 r# j};
4 p/ I# b1 ]. Z0 Z$ x; Q/ t; I
0 g8 e# c' a) u$ `+ bstatic struct gpio_led da850_evm_tl_leds[] = {
& |9 M" V6 |3 N8 Y {( ]: H+ |9 R* |+ P( Q/ r% L
.active_low = 0,; }* M6 o' @. u# Z" l
.gpio = DA850_USER_LED0,
' B2 Q9 B* S- L2 B6 c1 S) m# K7 n .name = "user_led0",0 v# W$ K q* |7 p2 y! _, U
.default_trigger = "default-on",
+ R- G; ^: y% i: Q. G0 j4 j: o },
6 p5 A' Z9 k$ o; R4 W; ~ {. c; q/ h0 C; G+ b# O: L
.active_low = 0,
1 \1 e* d9 h5 {' r .gpio = DA850_USER_LED1,! ] b# Y' D ~' I
.name = "user_led1",3 i9 h5 n6 E5 _
.default_trigger = "default-on",. b; d( t1 L- g3 D
},
) h( E8 k& g( d% M; G& I {
0 ~0 e7 X) A, r& K .active_low = 0,# }6 E- G7 o8 M$ c& S
.gpio = DA850_USER_LED2,) m4 M4 ? n1 ~
.name = "user_led2",: [4 p0 g+ f8 ~" b/ ~' p8 J
.default_trigger = "default-on",
8 J; H; I4 O; [8 G" ]) G$ C },5 k; a8 z0 Y- }, O3 m
{- t* M7 L" g7 \6 T7 r% }8 C
.active_low = 0,1 z4 [2 f6 A! I/ r1 X$ @0 K4 y
.gpio = DA850_USER_LED3,
) e" Y1 o3 Z! f: _; [/ | .name = "user_led3",
& @# [* y$ u4 f5 k, I$ \# Z, ` .default_trigger = "default-on",
# q. f) v9 J& ]! v, I/ g },
1 n* L, g% L3 \% m/ ~4 H' @: m};: y; z F# l; d3 o( e" ^
, L0 B4 R: l M* p% t, {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. h$ b" k1 r4 U9 M/ ~7 A .leds = da850_evm_tl_leds,0 k! X! t$ B% I) z% m2 ?( s; j/ n9 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. d) n8 B! v. {& l};& x" o- `) I; I4 f( B. ]
5 }# G) Y! K5 _
static void led_dev_release(struct device *dev)
5 [/ \4 ~; R, E) B$ f{
$ N2 `7 o6 d! \: ?};
! r1 M5 A. b4 q3 X* ?) }* ?% n5 @% A/ M. e0 s
static struct platform_device da850_evm_tl_leds_device = {9 L) a' `: o7 A: s
.name = "leds-gpio",: e) e6 X4 ^/ c& ^4 s" J7 \5 _
.id = 1,7 D6 I9 @: l$ I: I& U
.dev = {
; g) O ^5 D9 N7 o; V .platform_data = &da850_evm_tl_leds_pdata,/ m" R! a, s; J. N: Z. p- ~
.release = led_dev_release,
; [, i6 P8 @: a }# D' q: [; a) M/ `9 X& n
};
" x' l$ x# F0 M# b# s' K' N/ F) S3 ]. Y; k. h
static int __init led_platform_init(void)
2 U& u; y" G* V{: M8 b; p* f( @! I r
int ret;
5 l+ W7 Z0 n7 t; m) O$ ?( L#if 0* A1 D6 J3 {. P2 q# u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ i4 A+ ~3 c: T4 G) v$ }- O
if (ret)* V4 P, p5 U9 X& B7 r# ^2 h8 \ ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 n# v) s9 T: S& F" m+ B. _ "%d\n", ret);
6 j! T" f# `4 g#endif
7 T1 M' I: P# q& q0 B; T! F ret = platform_device_register(&da850_evm_tl_leds_device);4 q- |6 f! ^/ v, i }& @
if (ret)
& l W( \( V% M pr_warning("Could not register som GPIO expander LEDS"); r) ^+ ~% v6 H {( J
else
" w$ @* j) } m3 C4 l% ` printk(KERN_INFO "LED register sucessful!\n");6 J4 L& Z- D7 c( W8 E) ~" b; I
; {' u8 N: h( S/ i! _6 E return ret;3 Y4 r! o+ c7 U9 {8 l
}
. N# E% Q' x+ \. |
( \8 s7 J0 F0 h3 O- T: w, ]static void __exit led_platform_exit(void)
" O4 `5 k+ ]) Y- } e& A6 j{
+ s3 ^9 G: x' M' h Z @: } platform_device_unregister(&da850_evm_tl_leds_device);$ d$ ~& M6 P; H( W; l4 x. W% x
' W( t6 F" B* o4 z& z; U# x) I- Q
printk(KERN_INFO "LED unregister!\n");3 Q4 `) K3 w( r! T( L0 y8 N0 I, M f
}3 V7 w3 G, a) \' J4 @3 O
' i' S2 t9 }9 d* Z
module_init(led_platform_init);- \, {, Z4 }4 D; F7 t- i7 q
module_exit(led_platform_exit);
^, l* C! D' o Z2 A, ~5 v
9 j. D' ~9 o& @5 z2 z+ U$ ]1 @: LMODULE_DESCRIPTION("Led platform driver");* r, u, D9 |2 R& e; a* \
MODULE_AUTHOR("Tronlong");
$ g" s+ A, {! g4 c3 pMODULE_LICENSE("GPL");
( w9 D" ?4 i' D3 Y( ^& |3 \+ o) \" v
|
|