|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 N f& R+ J% E# s#include <linux/init.h># `! L( x9 K1 d
#include <linux/module.h>3 Z V z+ _. R# z3 l2 X
#include <linux/kernel.h>
, M6 n4 d' t# [6 f* J7 v#include <linux/types.h>0 k- N8 R6 w1 _( }1 d
#include <linux/gpio.h>
) V, P* ~2 F! R! u- n2 E7 B d#include <linux/leds.h>+ t, W- t* H u1 D4 s
#include <linux/platform_device.h>
$ x0 S2 I% ~1 K4 f+ B N f; L, D4 v7 b' l% i* P+ ]. w; m
#include <asm/mach-types.h>
' }1 i" [! Y# B, M0 b2 Y#include <asm/mach/arch.h>
( R9 \, E0 R& P O8 D7 ?#include <mach/da8xx.h>. c7 ?+ M% h4 R* X, Y6 {1 [& A
#include <mach/mux.h>
! J, X+ i' T$ M8 I( O1 i9 T2 S$ Z4 W4 h; I4 e9 E# L3 z' m3 e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' ^; l& Y" `# X: y( L0 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( l5 O% E8 }) f4 I( S0 f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ L) S4 t5 t6 }/ [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), |/ S/ n$ S, c0 [
1 K& o. Y! A0 @4 n h
/* assign the tl som board LED-GPIOs*/
8 R' ^& L2 G; p( Kstatic const short da850_evm_tl_user_led_pins[] = {4 {" z! c) V2 t7 s! U' Z( n* [
/* These pins are definition at <mach/mux.h> file */
4 N" ^: z, z, a# m- j. D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 f+ t- [7 L: `# @: C* u' q -1
7 W. U6 f) L+ D- F3 f5 _% b};4 L6 b, f5 H# k$ o6 {( V% Y
: A; c) e2 W$ `* x9 i* j. Y1 \6 p8 Hstatic struct gpio_led da850_evm_tl_leds[] = {
7 a5 E$ s* ^4 R { c2 t* w1 o6 d P$ @4 _+ F0 I$ Y
.active_low = 0,# x! \' u& m+ }/ A9 \+ \" {% b' Q
.gpio = DA850_USER_LED0,1 c# m) ?% Y( p6 o2 Z4 m4 S) x
.name = "user_led0",6 x3 Q% L" g2 T3 k& `% w% V: Z: `
.default_trigger = "default-on",
' r5 n3 a( O# w0 \6 N. g' v },( j: |! ^4 v* w6 Y9 }& v
{+ B. J% P+ H; K! t$ a; \
.active_low = 0,# D! h' b8 Y3 V) i' q, _! E
.gpio = DA850_USER_LED1,: G! {% g. X8 k, h! w
.name = "user_led1",
) {* r# c, A* j+ v/ g6 e8 S .default_trigger = "default-on",
* M! u3 _" W; q },
8 e! x! X6 S {- s$ W+ t {
* q% m; i% O$ Y, e, H .active_low = 0,
5 b- g$ H! r5 {) p$ s# R& W .gpio = DA850_USER_LED2,
! K# ^$ \4 t7 |: v .name = "user_led2",
/ `' M: T' l% i# ?: t .default_trigger = "default-on",' Y p9 z9 N5 H% I- C* ^( l. k
},
, r. _1 f I, _& O9 D {
$ w# f0 U8 N G! | .active_low = 0,
" ^( B$ c3 V% } .gpio = DA850_USER_LED3,
! ^1 H2 N& Y. p' ` .name = "user_led3",& e5 Z* F2 X: }+ q3 b
.default_trigger = "default-on",5 L, }6 [# ^ ]8 t; a( G6 s+ ?
},2 _4 U2 Q- s5 |9 Y, I2 d3 }
};+ y* |& J7 K/ N* M, [
5 ]; C# Y; s, \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 T8 z) B: i0 B3 Y/ N" H5 L9 J .leds = da850_evm_tl_leds,
: D* u! r5 _2 I$ [8 Y, M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ ~9 _ q, S+ a& f+ E% |
};
T5 }5 }4 a3 P$ H- R6 C
1 @& Z2 ]- e5 r, z9 U0 Bstatic void led_dev_release(struct device *dev)6 z7 D8 n' q9 d
{
( ^6 ?7 Y( n q3 q};
1 B. e2 v9 {. W4 h+ C0 k) T% @
4 O% {: }7 t- \+ K4 Q: k1 h9 A& ~static struct platform_device da850_evm_tl_leds_device = {
7 h \5 @( ^$ C+ p, ?7 ^8 O$ i .name = "leds-gpio",
3 R, I9 P4 h4 c2 B3 S* c" k .id = 1,
/ N. j4 P+ O) y. g1 N% m! d .dev = {
% O4 F" v! ?: [# E9 T .platform_data = &da850_evm_tl_leds_pdata,5 E7 v: O9 C# b% [- K2 K/ \) O
.release = led_dev_release,) L6 Q/ X1 r: {8 I: m7 Y/ e
}3 b8 g+ }4 b# `( {+ C b. x: X
};
8 @/ I% I+ f1 y8 F
9 x, v6 U, \3 z% r" \" kstatic int __init led_platform_init(void)7 \8 R5 w; {3 w6 |4 h2 c: Z
{
2 U3 R" `$ q# A, ^" j; V& P. t% G int ret;' d( n' c3 _/ P3 F& P* i
#if 08 E% U3 d+ a1 {. l" f. U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, G) x/ t' u2 l. r if (ret)
8 O5 P* F2 |4 z+ h1 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" j9 R6 \8 b2 B# L8 L "%d\n", ret);- {0 q& ~) z+ n h% C' |8 i! o
#endif
2 \$ r7 D) t d* t% x ret = platform_device_register(&da850_evm_tl_leds_device);
. I) a$ r2 }. v6 y# M$ Y" R! x if (ret)
( U8 A" Y' x" U; [2 o7 T8 e( P pr_warning("Could not register som GPIO expander LEDS");: Y% t N: n' ? _
else6 O7 Z' }/ y: K/ E
printk(KERN_INFO "LED register sucessful!\n");
5 R. z$ h3 K# T2 x2 B1 [
8 p8 u% K0 U5 J$ f return ret;1 p# C- ]8 X- a
}5 ^! s# V5 ?3 M2 s3 K8 D/ K, Z' e! p
9 T8 `% M) B1 ]- E# ]
static void __exit led_platform_exit(void)
0 l* { M3 l) h& s+ j( f& t{- M& \0 T2 l2 v1 g
platform_device_unregister(&da850_evm_tl_leds_device);4 b D$ G3 v/ F$ l7 _# K) j7 B* @
\. u% V1 V0 }" ^" f printk(KERN_INFO "LED unregister!\n");
$ x2 d* j5 o- K. T4 x6 ] L- ?0 k}
/ _% s8 B% N3 i; g( P9 Z3 x
8 f8 A' L8 j8 ]! y$ H$ fmodule_init(led_platform_init);. q6 O# O: Y, C0 _0 Z# k. v
module_exit(led_platform_exit);! Y4 B0 ?: Q. Z |2 @# O
! z& Q4 O, Y9 U
MODULE_DESCRIPTION("Led platform driver");! n9 V \( B& l( G
MODULE_AUTHOR("Tronlong");
% O4 w' B2 _* E i* Y9 AMODULE_LICENSE("GPL");
" ^" U! W) C, x4 X; P- a$ H8 x$ R( m9 u. c6 [# t
|
|